By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,950 Members | 1,032 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,950 IT Pros & Developers. It's quick & easy.

myMessage.body question

P: 56
Hello

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

Expand|Select|Wrap|Line Numbers
  1. myMessage.From = New MailAddress("info@mysite.net") 'Webmaster's email
  2. myMessage.To.Add(New MailAddress(strEmailValue)) 'user's email
  3. myMessage.Subject = ("Password Reset Request")
  4.  
  5. 'myMessage.Body = "Please click on the following link to reset your password: <br/>Link<br/><br/>Thank you<br/>"
  6.  
  7. myMessage.Body = ""            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
  8. myMessage.IsBodyHtml = True
  9. myMessage.Priority = MailPriority.Normal
  10.  
  11. Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
  12.  
  13. Dim mimeType As ContentType = New ContentType("text/html")
  14.  
  15. 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:

Expand|Select|Wrap|Line Numbers
  1. 'myMessage.Body = "Please click on the following link...
and set this to nothing

Expand|Select|Wrap|Line Numbers
  1.  myMessage.Body = ""
because I have included the body and link instead in the following two lines:

Expand|Select|Wrap|Line Numbers
  1. Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
  2.  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.
Apr 4 '18 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.