<%
'****************************************
'作者:zhengbi
'主页:http://www.glzy8.com/ok3w/
'QQ:124895502
'****************************************
Function JmailSend(toemail,Subject,Body)
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 = "myemail@163.com" '发送者地址
JMail.FromName = "myemail@163.com" '发送者姓名
JMail.Subject = Subject '邮件主题
JMail.MailServerUserName = "myemail" '身份验证的用户名
JMail.MailServerPassword = "mypass" '身份验证的密码
'设置优先级,范围从1到5,越大的优先级越高,3为普通
JMail.Priority = 3
JMail.ContentType = "text/html"
'JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
' 加入一个收件人【变量email:收件人地址】可以同一语句重复加入多个
emailTmp = Split(toemail,"|")'如果是多个收件人,请用|分隔
For i=0 To Ubound(emailTmp)
JMail.AddRecipient(emailTmp(i))
Next
'加入附件【变量filename:附件文件的绝对地址,确保用户IUSR_????有访问的权限】
'【参数设置是(True)否(False)为Inline方式】
'contentId = JMail.AddAttachment (filename, True)
'邮件主体(文本部分)
JMail.Body = Body
' 发送【调用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
JMail.Send("mail.k989.com")
'关闭并清除对象
JMail.Close()
Set JMail = Nothing
If Err.Number Then
Err.Clear
JmailSend = False
Else
JmailSend = True
End If
End Function
%>
<%
'=============调用示例==============
toemail = "email001@163.com|email002@163.com|email003@163.com"
Subject = "test"
Body = "My name is zhengbi"
If JmailSend(toemail,Subject,Body) Then
Response.Write("发送成功")
Else
Response.Write("发送失败")
End If
%>