w3JMail4.4免费下载级使用说明(例子)

Click Here To Download

<%
On error resume next
Dim JMail, contentId
Set JMail = Server.CreateObject("JMail.Message")
JMail.Charset = "gb2312" ‘邮件字符集,默认为"US-ASCII"
‘ JMail.ISOEncodeHeaders = False ‘ 是否进行ISO编码,默认为True

‘ 发送者信息(可用变量方式赋值)
JMail.From = "username@domain.com" ‘ 发送者地址
JMail.FromName = "名字" ‘ 发送者姓名
JMail.Subject = "主题" ‘ 邮件主题

‘ 身份验证
JMail.MailServerUserName = "username" ‘ 身份验证的用户名
JMail.MailServerPassword = "password" ‘ 身份验证的密码(这里用到的用户名与密码和上面发送者地址的信箱要一致)

‘ 设置优先级,范围从1到5,越大的优先级越高,3为普通
JMail.Priority = 3

JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")

‘ 加入一个收件人【变量email:收件人地址】可以同一语句重复加入多个
JMail.AddRecipient "jena.want@gmail.com","迦楠"
JMail.AddRecipient "jena.want@yahoo.com","迦楠"

‘ 加入附件【变量filename:附件文件的绝对地址,确保用户IUSR_机器名有访问的权限】
‘ 【参数设置是(True)否(False)为Inline方式】
‘contentId = JMail.AddAttachment (Server.MapPath("jmail_template.asp"), True)

‘ 邮件主体(HTML(注意信件内链接附件的方式))
JMail.HTMLBody = "<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0 Transitional//EN"" ""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd""><html xmlns=""http://www.w3.org/1999/xhtml""><head><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312"" /><title>无标题文档</title><style type=""text/css"">body,td,th {font-family: Georgia, Times New Roman, Times, serif;font-size: 14px;}body {margin-left: 0px;margin-top: 0px;margin-right: 0px;margin-bottom: 0px;}</style></head><body><table width=""100%"" border=""0"" cellspacing=""0"" cellpadding=""3""><tr><td>亲爱的 迦楠 : </td></tr><tr><td></td></tr><tr><td>&nbsp;</td></tr><tr><td><font color=red size=5>邮件正文</font>,邮件正文,邮件正文</td></tr><tr><td align=""center"">jena.want</td></tr></table></body></html>"

‘ 邮件主体(文本部分)
JMail.Body = "我们的邮件采用了HTML格式,但是您的邮件查看软件可能不支持。。。邮件正文,邮件正文,邮件正文"

‘ 发送【调用格式:JMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send("smtp.163.com")

‘ 关闭并清除对象
JMail.Close()
Set JMail = Nothing

if err.number<>0 then
 response.write "邮件发送失败!"
 response.write err.description
else
 response.write "邮件发送成功!"
end if
%>

1 Comment

 Add your comment
  1. 现在已经有自己的邮件服务器了,哈哈 :)

Leave a Comment

Your email address will not be published.

*