📄 email.asp
字号:
<%
dim EmailFlag
dim SMTPServer
dim SMTPAccount,SMTPPwd
call getmailvar()
dim mailfrom,mailto,mailtopic,mailbody
dim SendMailStatus
'emailflag=4
sub Jmail_msg()
dim msg
on error resume next
set msg = Server.CreateOBject( "JMail.Message" )
if err then
SendMailStatus=err.description
err.clear
exit sub
end if
msg.silent = true
msg.Logging = true
msg.Charset ="gb2312"
msg.ContentType = "text/html"
msg.From = mailfrom
'msg.FromName = "Sender name" '发件人姓名
msg.RePlyTo = mailfrom '回复地址
rcpt=split(mailto,",")
for i=0 to ubound(rcpt)
msg.AddRecipient rcpt(i) '增加收件人
next
msg.Subject = mailtopic
msg.Body = mailbody
'msg.AppendText(textYouWantToAppend)
if SMTPAccount<>"" then msg.MailServerUserName = SMTPAccount '您的邮件服务器登录名
if SMTPPwd<>"" then msg.MailServerPassword = SMTPPwd '登录密码
if not msg.Send(SMTPServer ) then 'SMTP服务器地址
SendMailStatus="<pre>" & msg.log & "</pre>"
else
SendMailStatus="OK"
end if
Set msg=nothing
end sub
'emailflag=1
sub Jmail_smtp()
Dim JMail
on error resume next
Set JMail=Server.CreateObject("JMail.SMTPMail")
if err then
SendMailStatus=err.description
err.clear
exit sub
end if
JMail.Logging=True
JMail.Charset="gb2312" '设定邮件的字符集
JMail.ContentType = "text/html" '缺省是"text/plain",以HTML格式发送邮件, 应为"text/html"
JMail.ServerAddress=SMTPServer
JMail.Sender=mailfrom
JMail.Subject=mailtopic
JMail.Body=mailbody
rcpt=split(mailto,",")
for i=0 to ubound(rcpt)
JMail.AddRecipient rcpt(i) '增加收件人
next
'JMail.AddRecipientBCC mailBCC '增加密件收件人
'JMail.AddRecipientCC mailCC '增加抄送收件人
JMail.Priority=3 '邮件的优先级,优先级. 范围在1-5之间。越大的优先级约高,5最高,1最低,一般设置为3
JMail.Execute
Set JMail=nothing
if err then
SendMailStatus=err.description
err.clear
else
SendMailStatus="OK"
end if
end sub
'emailflag=2
sub Cdonts()
dim objCDOMail
on error resume next
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
if err then
SendMailStatus=err.description
err.clear
exit sub
end if
objCDOMail.From =mailfrom
objCDOMail.To =mailto
rem objCDOMail.Cc =MailCc
rem objCDOMail.Bcc =MailBcc
objCDOMail.Subject =mailtopic
objCDOMail.BodyFormat = 0 '0 HTML / 1 Text
objCDOMail.MailFormat = 0 'MIME
objCDOMail.Body =mailbody
objCDOMail.Importance = 1
' : 0 - 低重要性
' : 1 - 中等重要性(默认)
' : 2 - 高重要性
' objCDOMail.AttachFile =
objCDOMail.Send
Set objCDOMail = Nothing
if err then
SendMailStatus=err.description
err.clear
else
SendMailStatus="OK"
end if
end sub
'emailflag=3
sub aspemail()
on error resume next
Set mailer=Server.CreateObject("ASPMAIL.ASPMailCtrl.1")
if err then
SendMailStatus=err.description
err.clear
exit sub
end if
recipient=mailto
sender=mailfrom
subject=mailtopic
message=mailbody
mailserver=SMTPServer
result=mailer.SendMail(mailserver, recipient, sender, subject, message)
if err then
SendMailStatus=err.description
err.clear
else
SendMailStatus="OK"
end if
end sub
sub getmailvar()
dim mailrs
set mailrs=conn.execute("select emailflag,smtpserver,smtpaccount,smtppwd from config")
EmailFlag=mailrs(0)
SMTPServer=mailrs(1)
SMTPAccount=mailrs(2)
SMTPPwd=mailrs(3)
set mailrs=nothing
end sub
%>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -