myMessage.body question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Bluenose
    New Member
    • Apr 2012
    • 56

    myMessage.body question

    Hello

    In the following SMTP code, have I coded myMessage.Body correctly, please?

    Code:
    myMessage.From = New MailAddress("info@mysite.net") 'Webmaster's email
    myMessage.To.Add(New MailAddress(strEmailValue)) 'user's email
    myMessage.Subject = ("Password Reset Request")
                
    'myMessage.Body = "Please click on the following link to reset your password: <br/>Link<br/><br/>Thank you<br/>"
    
    myMessage.Body = ""            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
    myMessage.IsBodyHtml = True
    myMessage.Priority = MailPriority.Normal
    
    Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
    
    Dim mimeType As ContentType = New ContentType("text/html")
                
    Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:dimaHeader><br /><br /><br ><body style='font-family:candara; color:#ffffff; background-color:#858585; margin-left:2em;'>Hello " & strEmailValue & "<br /><br /> To reset your password, please click on this <a href='http://www.dimadayoub.net/newPassword.aspx?token=" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='http://www.dimadayoub.net' target='_blank' style='color: #0000FF; text-decoration: none;'>http://www.dimadayoub.net</a></body>", Nothing, "text/html")
    I have commented out:

    Code:
    'myMessage.Body = "Please click on the following link...
    and set this to nothing

    Code:
     myMessage.Body = ""
    because I have included the body and link instead in the following two lines:

    Code:
    Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
     Dim HtmlMessage As AlternateView = AlternateView.CreateAlternateViewFromString("<img src=cid:dimaHeader><br /><br /><br ><body style='font-family:candara; color:#ffffff; background-color:#858585; margin-left:2em;'>Hello " & strEmailValue & "<br /><br /> To reset your password, please click on this <a href='http://www.dimadayoub.net/newPassword.aspx?token=" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='http://www.dimadayoub.net' target='_blank' style='color: #0000FF; text-decoration: none;'>http://www.dimadayoub.net</a></body>", Nothing, "text/html")
    The idea is that the HTML-email that is sent to the user who has forgotten his password, contains a link for him to
    reset his password, but I am getting an 'Authentication required' error. Despite the server error, it is unrelated to SMTP credentials, so I am trying to isolate where the problem really lies.

    Thanks.
Working...