用HTML格式发送邮件
类别: ASP教程
你可以通过SMTP服务或者MS Exchange发送HTML格式的邮件,但是,你需要注意的是,并不是所有的clients都可以正常显示。在通常的情况下,CDONTS发送邮件是使用plain-text格式。在使用HTML方式的时候我们可以进行更多的设置,例如不同的字体,颜色,插入图片等等。下面是一个例子
<%
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.AttachURL "D:imagesmyImage.gif", "myImage.gif"
objMail.AttachURL "D:imagesmyImage2.gif", "myImage2.gif"
HTML = HTML & "<HTML>"
HTML = HTML & "<HEAD>"
HTML = HTML & "<TITLE>Send Mail with HTML</TITLE>"
HTML = HTML & "</HEAD>"
HTML = HTML & "<BODY bgcolor=""lightyellow"">"
HTML = HTML & "<TABLE cellpadding=""4"">"
HTML = HTML & "<TR><TH><FONT color=""darkblue"" SIZE=""4"">"
HTML = HTML & now() & " - "
HTML = HTML & "These are all great ASP Sites</FONT></TH></TR>"
HTML = HTML & "<TR><TD>"
HTML = HTML & "<A HREF=""http://www.etoow.com"">"
HTML = HTML & "<IMG SRC=""myImage.gif""></A><BR><BR>"
HTML = HTML & "<A HREF=""http://www.etoow.com"">"
HTML = HTML & "<IMG SRC=""myImage2.gif""></A><BR><BR>"
HTML = HTML & "</FONT></TD></TR></TABLE><BR><BR>"
HTML = HTML & "</BODY>"
HTML = HTML & "</HTML>"
objMail.From = "rob@fcxx.net"
objMail.Subject = "Your daily HTML Mail"
\'you need TO add these lines FOR the mail
\'to be sent in HTML format
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.To = "you@4ico.com"
objMail.Body = HTML
objMail.Send
Response.write("Mail was Sent")
set objMail = nothing
%>
<%
Dim objMail
Set objMail = Server.CreateObject("CDONTS.NewMail")
objMail.AttachURL "D:imagesmyImage.gif", "myImage.gif"
objMail.AttachURL "D:imagesmyImage2.gif", "myImage2.gif"
HTML = HTML & "<HTML>"
HTML = HTML & "<HEAD>"
HTML = HTML & "<TITLE>Send Mail with HTML</TITLE>"
HTML = HTML & "</HEAD>"
HTML = HTML & "<BODY bgcolor=""lightyellow"">"
HTML = HTML & "<TABLE cellpadding=""4"">"
HTML = HTML & "<TR><TH><FONT color=""darkblue"" SIZE=""4"">"
HTML = HTML & now() & " - "
HTML = HTML & "These are all great ASP Sites</FONT></TH></TR>"
HTML = HTML & "<TR><TD>"
HTML = HTML & "<A HREF=""http://www.etoow.com"">"
HTML = HTML & "<IMG SRC=""myImage.gif""></A><BR><BR>"
HTML = HTML & "<A HREF=""http://www.etoow.com"">"
HTML = HTML & "<IMG SRC=""myImage2.gif""></A><BR><BR>"
HTML = HTML & "</FONT></TD></TR></TABLE><BR><BR>"
HTML = HTML & "</BODY>"
HTML = HTML & "</HTML>"
objMail.From = "rob@fcxx.net"
objMail.Subject = "Your daily HTML Mail"
\'you need TO add these lines FOR the mail
\'to be sent in HTML format
objMail.BodyFormat = 0
objMail.MailFormat = 0
objMail.To = "you@4ico.com"
objMail.Body = HTML
objMail.Send
Response.write("Mail was Sent")
set objMail = nothing
%>
- 上一篇: ASP HTTP 使用范例
- 下一篇: CHARTFX用法
-= 资 源 教 程 =-
文 章 搜 索