在WIN2000环境下 我们可以利用系统自带的邮件服务器发送HTML邮件。
需要注意的是: 发送HTMLmail之前一定要对发送的主内容进行UBB转换 ,本例中就是使用 DvBCode(Request("vcontent")) ,对来自文本域vcontent 的内容进行UBB格式化后再发送
至于UBB代码请参考本站 :
教程
<%
‘定义邮件变量
Dim objMail,mybody
Dim thisfrom,thiscontent
’创建邮件实体
Set objMail = CreateObject("CDONTS.Newmail")
‘获得收件人EMAIL.
objMail.TO = Request("vfname")
‘获得发件人EMAIL.
objMail.From = Request("vname")
‘‘获得邮件主题.
objmail.Subject = "三叶草-"&Request("vtitle")
‘设定邮件类型.
objMail.MailFormat = cdoMailFormatMime
objMail.BodyFormat = cdoBodyFormatHTML
'定义HTML邮件主题
mybody= "<html>" & _
"<head> "& _
"<title>三叶草特别推荐</title>" & _
"<meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"">" & _
"<style type=""text/css"">" & _
"td,li,select,input,textarea {font-size:12px}" & _
".f7 {font-size:7px;}" & _
".f16{font-size:16px;}" & _
".f12{font-size:12px;}" & _
".f14{font-size:14px;}" & _
".f18{font-size:18px;color: #FF6600;}" & _
".title {FONT-WEIGHT: bold; FONT-SIZE: 16px; COLOR: #cc0000; FONT-FAMILY: ""Verdana""}" & _
"A {dovia:expression(this.onfocus=this.blur);}" & _
"A:link {COLOR: #333333; TEXT-DECORATION: none}" & _
"A:visited {COLOR: #333333; TEXT-DECORATION: none}" & _
"A:hover {LEFT: 1px; COLOR: #3399cc; POSITION: relative; TOP: 1px; TEXT-DECORATION: underline}" & _
"</style></head>" & _
"<body>" & _
"<table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""0"">" & _
"<tr><td height=""25"" bgcolor=""#f3f3f5"">三叶草文章推荐 此信件来自您的朋友"&Request("vname")&"</td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""25"">您的朋友 <font color=""#CC0000"">"&Request("vname")&"</font> 特别向您推荐此文章 </td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""20"">相关链接: "&"<a href="&nurl&" target=""_blank"">"&nurl&"</a></td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""20""><font color=""#CC0000"">朋友附言:</font>"&DvBCode(Request("vcontent"))&"</td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""25"">以下为文章内容:</td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""30"" align=""center"" bgcolor=""#f5f5f3"">"&Request("vtitle")&"</td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""25"" bgcolor=""#f5f5f3"">"&filecontent&"</td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""25"" align=""center""><p><br>" & _
"此信件来自您的朋友"&Request("vname")&",欢迎访问<font color=""#CC0000"">三叶草</font></p>" & _
"<p>www.dovia.net</p></td>" & _
"</tr>" & _
"<tr>" & _
"<td height=""25""> </td>" & _
" </tr>" & _
"</table>" & _
"</body>" & _
"</html>"
objMail.Body =mybody
’发送邮件
objMail.send
set objMail = Nothing
‘发送完成后转向
Response.Redirect "sender.asp?action=go"
%>
关键代码已经给出注释,你可以将具体内容修改你的情况。