How to send e-mails using a web service

Hello guys!

Anyone knows how can I send an e-mail, with attachments, using a web service

The scenario is: I have a web application that will process some requests and after all done it will access a web service, used by other existing apps, to send a default e-mail to the user's inbox.

Thanks!
Rafael Nascimento



Answer this question

How to send e-mails using a web service

  • BMcCool

    Hai Dude

    I made a mistake in the above post i forgot to include the code . So with this iam posting the code .

    NOTE :

    Sending Mail is very easy in ASP.NET. Before you run this program you need to do some settings in SMTP server.

    Plz open IIS--> SMTP --> Properties-->Access Tab-->Click Relay Button-->Select Only the List below Radio Button and then Press Add Button-->Select Single User Radio button and then enter IP address as 127.0.0.1-->Click OK and Apply.

    Once you do all the settings above then run the asp.net program. Then it works perfectly. Remeber you must do the above settings. If it won't work plz e-mail me.

    CODE :

    Sub bottonSend_Click(sender As Object, e As EventArgs)

    Dim emailMessage as MailMessage
    emailMessage=New MailMessage
    emailMessage.From=txtFrom.Text
    emailmessage.CC=txtCC.Text
    emailMessage.To=textTo.Text
    emailMessage.Subject=textSubject.Text
    emailMessage.Body=textMessage.Text
    SmtpMail.SmtpServer="localhost"
    Try
    SmtpMail.Send(emailMessage)
    labelStatus.Text="Message sent!"
    buttonSend.Enabled=False
    Catch ex as Exception
    labelStatus.Text="Unable to send the e-mail message"
    End Try
    End Sub

    Sub bottonNewMessage_Click(sender As Object, e As EventArgs)

    textTo.Text=""
    textSubject.Text=""
    textMessage.Text=""
    buttonSend.Enabled=True
    labelStatus.Text=""
    txtFrom.Text=""
    txtCC.Text=""
    End Sub

    And if you any query regrading this please mail me .


  • pkv

    Hi

    I am having birthday application in which I need to check perticular date with database and send emails automatically to user on his/her birthday according to system date.

    How to handle this situation.

    Thanks & Regards,

    Firoj$


  • archdeacon

    Why bother with a web service to do this. The web page itself could send the email.

    Take alook at the System.Net.Mail namespace. It allows you to send the emails via SMTP using the MailMessage class.

    http://msdn2.microsoft.com/en-us/library/system.net.mail.aspx

    Example code:

    http://www.eggheadcafe.com/articles/20050505.asp

    If you want, you can have a WebService WebMethod send the email, but there would be no tangible benefit.

  • Silmar

    Hai Dude

    I have a nice code for that .It send the email to your in box . With this i try to send this



    Sending Mail is very easy in ASP.NET. Before you run this program you need to do some settings in SMTP server.

    Plz open IIS--> SMTP --> Properties-->Access Tab-->Click Relay Button-->Select Only the List below Radio Button and then Press Add Button-->Select Single User Radio button and then enter IP address as 127.0.0.1-->Click OK and Apply.

    Once you do all the settings above then run the asp.net program. Then it works perfectly. Remeber you must do the above settings. If it won't work plz e-mail me.




  • How to send e-mails using a web service