Saturday, March 24, 2012

html email not sending properly

Is there anything wrong with this ? I can't figure out why it does not work properly. I receive the email, but when I open the email in outlook express I see the HTML and BODY tags as plain text.

Am I doing something wrong? All my other emails seem to send fine.

Thanks for any assistance.

mike123

Dim objMail As New MailMessage()
objMail.BodyFormat = MailFormat.Html
SmtpMail.Send("bob@dotnet.itags.org.hotmail.com", "admin@dotnet.itags.org.123.com", "subject", "<html><body><br><br>Username: <a href='http://www.123.com/a.aspx?userID=" & CStr(Session("id#")) & "' target='_blank'>" & CStr(Session("id")) & "</a><br><br>" & Request.Form("message") & "</body></html>")
objMail = Nothing

hello,

The way you are using the SmtpMail.Send would ignore objmail making it obsolete and useless...

try:


Dim objMail As New MailMessage()

objMail.BodyFormat = MailFormat.Html

objMail.To = "whoever@.mail.com"
objMail.From = "whoeveritsfrom@.mail.com"

objMail.Subject = "Subject Line"
objMail.Body = "<html><body>YOUR HTML HERE</BODY></HTML
SmtpMail.Send(objMail)

objMail = Nothing

Hope that helps
The version of SmtpMail.Send you are calling is only a shortcut that sends its own mail message. Under the covers, it creates a MailMessage object, fills it with the parameters you passed in, and sends it. So, it does not use the MailMessage object you created just before calling SmtpMail.Send. And, this method assumes the body type is text.

Instead, you should fill in the MailMessage object you created, and pass it into SmtpMail.Send, as follows:


Dim objMail as New MailMessage()
objMail.BodyFormat = MailFormat.Html
objMail.From = "bob@.hotmail.com"
objMail.To = "admin@.123.com"
objMail.Subject = "subject"
objMail.Body = "......"
SmtpMail.Send(objMail)

awesome, thanks!

No comments:

Post a Comment