Eric
Eric

Reputation: 8078

Send HTML email asp

I want to add some html in an email. I've tried the following.

vFromName = "someone"
vFromAddress = "someemail"
vTo = "recipient"
vSubject="someSubject"
vBodyofemail = "<html><table><tr><td><b>SomeText</b></td></tr></table></html>"

Call SendMail()

sub SendMail()
  'change to address of your own SMTP server
  strHost = "mail.internal.rouses.com"
  Set Mail = Server.CreateObject("Persits.MailSender")
  'enter valid SMTP host
  Mail.Host = strHost
  'From eMail address
  Mail.FromName = vFromName
  'From address
  Mail.From = vFromAddress 
  'To eMail address
  Mail.AddAddress vTo
  'message subject
  Mail.Subject = vSubject
  'message body
  Mail.Body = vBodyOfEmail
 Mail.Send
end sub

How can i do this? I've tried Mail.HtmlBody but that doesn't work either. The email is sent but all i see are the tags where the html is.

Upvotes: 3

Views: 6303

Answers (3)

Arjan
Arjan

Reputation: 23529

Not an answer to your question, but shouldn't all messages include plain text as well? Without plain text, you'll surely get a higher spam score.

(And people like myself prefer to switch to plain text if your HTML/CSS is not rendered well. See Guide to CSS support in email clients (2008), and the list at the Email Standards Project.)

Upvotes: 0

RSolberg
RSolberg

Reputation: 26972

Try adding this line above the send call.

Mail.IsHTML = true

Without it, the Mail object defaults to standard text and whatever is typed into the Body property will be rendered in the email as text.

Upvotes: 3

C. Ross
C. Ross

Reputation: 31848

According to this page you need to set the IsHTML flag to true.

strHTML = "Hello world"

Mail.IsHTML = True
Mail.Body = "<HTML><BODY><CENTER>" & strHTML & "</CENTER></BODY></HTML>"

Upvotes: 3

Related Questions