Sending Email in ASP.NET 2.0

Discussion in 'ASP.NET 2.0' started by ashrafcsnet, Dec 23, 2006.

  1. If any one could help me with my problem, I want to send an email but it doesn't work instead the Success message appears on the page.


    Here is the code for the page.


    Dim strFrom = txtFrom.Text


    Dim strTo = txtTo.Text


    Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))


    MailMsg.BodyEncoding = Encoding.Default


    MailMsg.Subject = "Subject"


    MailMsg.Body = "This is a sample message"


    MailMsg.Priority = MailPriority.High


    MailMsg.IsBodyHtml = True


    'Smtpclient to send the mail message


    Dim SmtpMail As New SmtpClient


    SmtpMail.Host = "localhost"


    SmtpMail.Send(MailMsg)


    Response.Write("Success...")
     
  2. Nothing sent to my junk or bulk mail...
     
  3. Nothing keeping that success message from printing...

    Please take a look at the tutorial videos and sample code at www.asp.net
     
  4. Try hard coding the 'To' address instead trying to pass variables to it. This helps eliminate point of failure of the email. Also make sure you have a valid 'From' address. Getting bounce back messages or error messages can really help in finding out where is the cause of failure of the email application.
     

Share This Page