知行合一

用Jmail实现ASP程序自动发送邮件和邮件群发

因为需要这自动发邮件功能,现在的服务器一般都支持 jmail 发信,就从网上搜了一合适的………….

首先服务器要支持JMail~~`
然后代码如下了~`根据情况自己改~~`

<%
mailserver=”smtp.sina.com.vn” ‘smtp服务器地址
mailname=”111111@sina.com” ‘发信邮箱
mailpassword=”这里填写密码” ‘发信邮箱密码
dim msg
CLStr=Chr(13) & Chr(10)
Set msg = Server.CreateObject(“JMail.Message”)
msg.silent = true
msg.Logging = true
msg.Charset = “gb2312”
msg.MailServerUserName = mailname
msg.MailServerPassword = mailpassword  
msg.From = mailname
msg.FromName = mailname
msg.AddRecipient (UserMail)                      ‘usermail为网站会员注册时填写的ID
msg.Subject = “您在“”&sitename&””注册成功”
msg.Body = UserName&”,您好!”&CLStr&CLStr
msg.Body = msg.Body&”恭喜您注册会员成功,会员ID:”&userid&”,登陆密码:”&user_password&CLStr&CLStr
msg.Body = msg.Body&sitename&”(“&siteurl&”)欢迎您多多光临!谢谢!”&CLStr
msg.Send (mailserver)
msg.close
set msg = nothing
%>

这个测试过,ok

ASP实现邮件群发

<%  
function   SendMail(subject,msg)  
dim   JMail  
‘on   error   resume   next  
Set   JMail   =   Server.CreateObject(“JMail.SMTPMail”)  
JMail.LazySend   =   true  
JMail.silent   =   true  
JMail.Charset   =   “gb2312”  
JMail.ContentType   =   “text/html”  
JMail.Sender   =   “1111@sina.com”  
JMail.ReplyTo   =   “1111@sina.com”  
JMail.SenderName   =   “sina”  
JMail.Subject   =   subject  
JMail.SimpleLayout   =   true  
JMail.Body   =   msg  
JMail.Priority   =   1  
 
        aryEmail   =   split(textemail1,   “;”)  
for   i=0   to   UBound(aryEmail)  
    JMail.AddRecipient   Trim(aryEmail(i))  
next    
 
JMail.AddHeader   “Originating-IP”,   Request.ServerVariables(“REMOTE_ADDR”)  
SendMail   =   JMail.Execute()  
JMail.Close  
set   JMail=nothing  
end   function  
%>

赞(0) 打赏
未经允许不得转载:嘟嘟鱼 » 用Jmail实现ASP程序自动发送邮件和邮件群发
分享到: 更多 (0)

觉得文章有用就打赏一下文章作者

支付宝扫一扫打赏

微信扫一扫打赏