Send HTML email asp

霸气de小男生 提交于 2019-12-23 15:44:06

问题


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.


回答1:


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>"



回答2:


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.




回答3:


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.)



来源:https://stackoverflow.com/questions/1079740/send-html-email-asp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!