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

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

Expand|Select|Wrap|Line Numbers
  1. myMessage.From = New MailAddress("") 'Webmaster's email
  2. myMessage.To.Add(New MailAddress(strEmailValue)) 'user's email
  3. myMessage.Subject = ("Password Reset Request")
  5. 'myMessage.Body = "Please click on the following link to reset your password: <br/>Link<br/><br/>Thank you<br/>"
  7. myMessage.Body = ""            myMessage.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
  8. myMessage.IsBodyHtml = True
  9. myMessage.Priority = MailPriority.Normal
  11. Dim PlainMessage As AlternateView = AlternateView.CreateAlternateViewFromString("Hello. To reset your password, please click on this link", Nothing, "text/plain")
  13. Dim mimeType As ContentType = New ContentType("text/html")
  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='" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='' target='_blank' style='color: #0000FF; text-decoration: none;'></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='" & uniqueCode & "' style='color: #0000FF; text-decoration: none;'>link</a><br /><br />Thank you<br /><br />Regards<br /></br />Dima<br /><br ><a href='' target='_blank' style='color: #0000FF; text-decoration: none;'></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.

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.