日期:2012-04-16  浏览次数:20869 次

<%'By Dicky QQ:25941
Function JMail(Send_From,Send_To,Send_Subject,Send_Body)
'调用JMail组件
'发送E-mail函数
'參數:
'Send_From-發送者信箱
'Send_To-接受者信箱
'Send_Subject-郵件主題
'Send_Body-郵件内容
Dim JMail
Set JMail = Server.CreateObject("JMail.Message")

JMail.Charset = "gb2312" ' 邮件字符集,默认为"US-ASCII"
' JMail.ISOEncodeHeaders = False ' 是否进行ISO编码,默认为True

' 发送者信息(可用变量方式赋值)
JMail.From = Send_From ' 发送者邮箱
JMail.FromName = "管理员" ' 发送者姓名
JMail.Subject = Send_Subject ' 邮件主题

' 身份验证
'JMail.MailServerUserName = "user" ' 身份验证的用户名
'JMail.MailServerPassword = "password" ' 身份验证的密码

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

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

' 加入一个收件人【变量Send_From:收件人地址】可以同一语句重复加入多个
JMail.AddRecipient(Send_From)

' 邮件主体(HTML(注意信件内链接附件的方式))
JMail.HTMLBody = UBBCode(Send_Body)
JMail.Body = HTMLDecode(UBBCode(Send_Body))

' 发送【调用格式:objJMail.Send([username:password@]SMTPServerAddress[:Port])】
'JMail.Send("user:password@smtp.21cn.com")
SendInfo=JMail.Send(Send_To)

' 关闭并清除对象
JMail.Close()
Set JMail = Nothing
End Function

Function Send_Mail(Send_From,Send_To,Send_Subject,Send_Body)
'调用Windows自带NewMail组件
'发送E-mail函数
'參數:
'Send_From-發送者信箱
'Send_To-接受者信箱
'Send_Subject-郵件主題
'Send_Body-郵件内容
Dim mailObject
Set mailObject = Server.CreateObject("CDONTS.NewMail")
mailObject.BodyFormat = 0
mailObject.MailFormat = 0
mailObject.From = Send_From
mailObject.To = Send_To
mailObject.Subject = Send_Subject
mailObject.Body = Send_Body
mailObject.Send()
Set mailObject = Nothing

If Err Then
Response.Write "<script language=javascript>alert('Error:"& Err.Number & Err.Description &"對不起,郵件發送失敗!:(');</script>"
Else
Response.Write "<script language=javascript>alert('恭喜,郵件發送成功!^_^');</script>"
End If
End Function %>