时间:2021-07-01 10:21:17 帮助过:44人阅读
Function IsObjInstalled(strClassString)
On Error Resume Next
IsObjInstalled = False
Err = 0
Dim xTestObj
Set xTestObj = Server.CreateObject(strClassString)
If 0 = Err Then IsObjInstalled = True
Set xTestObj = Nothing
Err = 0
End Function
判断代码:
if IsObjInstalled("JMail.Message")=True then{
if IsObjInstalled("JMail.Message") =True then
SendStat = Jmail("***@jb51.net","来自网上的客户留言","<html><head><meta http-equiv=""Content-Type"" content=""text/html; charset=gb2312""><title>网站用户留言</title></head><body>留言人:"&txtname&"<br>性别:"&xingbie&"<br>咨询网站:"&txtweb&"<br>联系方式:"&txttel&"<br>留言内容:"&content&"<br>IP地址:"&ipaddress&"<br>留言时间:"&now()&"<br><br>本邮件由系统自动发送,无须回复<!--脚本之家www.gxlsystem.com--><br><br></body></html>","GB2312","text/html")
end if
}
jmail发信函数
代码如下:
' ============================================
' jmail发送邮件
' ============================================
Function Jmail(mailTo,mailTopic,mailBody,mailCharset,mailContentType)
'入口参数:
' mailTo 收件人email地址
' mailTopic 邮件主题
' mailBody 邮件正文(内容)
' mailCharset 邮件字符集,例如GB2312或US-ASCII
' mailContentType 邮件正文格式,例如text/plain或text/html
'返回值:
' 字符串,发送成功后返回OK,不成功返回错误信息
'使用方法:
' 1)设置好常量,即以Const开头的变量
' 2)使用类似如下代码发信
'Dim SendStat
'SendStat = Jmail("aa@163.com","测试Jmail","这是一封<br/>测试信!","GB2312","text/html")
'Response.Write SendStat
'***************根据需要设置常量开始*****************
Dim ConstFromNameCn,ConstFromNameEn,ConstFrom,ConstMailDomain,ConstMailServerUserName,ConstMailServerPassword
ConstFromNameCn = "彩票网"'发信人中文姓名(发中文邮件的时候使用),例如‘张三'
ConstFromNameEn = "bc5"'发信人英文姓名(发英文邮件的时候使用),例如‘zhangsan'
ConstFrom = "jb51@163.com"'发信人邮件地址,例如‘zhangsan@163.com'
ConstMailDomain = "smtp.163.com"'smtp服务器地址,例如smtp.163.com
ConstMailServerUserName = "jb51@163.com"'smtp服务器的信箱登陆名,例如‘zhangsan'。注意要与发信人邮件地址一致!
ConstMailServerPassword = "www.gxlsystem.com"'smtp服务器的信箱登陆密码
'***************根据需要设置常量结束*****************
'-----------------------------以下内容无需改动------------------------------
On Error Resume Next
Dim myJmail
Set myJmail = Server.CreateObject("JMail.Message")
myJmail.Logging = False'记录日志
myJmail.ISOEncodeHeaders = False'邮件头不使用ISO-8859-1编码
myJmail.ContentTransferEncoding = "base64"'邮件编码设为base64
myJmail.AddHeader "Priority","3"'添加邮件头,不要改动!
myJmail.AddHeader "MSMail-Priority","Normal"'添加邮件头,不要改动!
myJmail.AddHeader "Mailer","Microsoft Outlook Express 6.00.2800.1437"'添加邮件头,不要改动!
myJmail.AddHeader "MimeOLE","Produced By Microsoft MimeOLE V6.00.2800.1441"'添加邮件头,不要改动!
myJmail.Charset = mailCharset
myJmail.ContentType = mailContentType
If UCase(mailCharset) = "GB2312" Then
myJmail.FromName = ConstFromNameCn
Else
myJmail.FromName = ConstFromNameEn
End If
myJmail.From = ConstFrom
myJmail.Subject = mailTopic
myJmail.Body = mailBody
myJmail.AddRecipient mailTo
myJmail.MailDomain = ConstMailDomain
myJmail.MailServerUserName = ConstMailServerUserName
myJmail.MailServerPassword = ConstMailServerPassword
myJmail.Send ConstMailDomain
myJmail.Close
Set myJmail=nothing
If Err Then
Jmail=Err.Description
Err.Clear
Else
Jmail="OK"
End If
On Error Goto 0
End Function