asp邮件发送代码,已测试

首先安装jmail这个网上很多提供的,在这里我也给大家一个把

http://down.chinaz.com/soft/526.htm

 

 

代码如下,只需稍加修改即可。

<% 

cname="名称"

cemail="407593529@qq.com"

emailtitle="标题"

emailcontant="内容"

Set JMail = Server.CreateObject("JMail.Message") 

'是否将信头编码成iso-8859-1字符集. 缺省是True 

JMail.ISOEncodeHeaders = True 

'如果JMail.silent设置为true,ErrorCode包含的是错误代码 

JMail.Silent = True 

'设置标题和内容编码,如果标题有中文,必须设定编码为gb2312 

'JMail.Charset = "gb2312" 

'JMail.ContentType = "text/html" '如果发内嵌附件一定要注释掉这行,重要! 

JMail.From = "zhaoyingjie1008@163.com" ' 发送者地址 

JMail.FromName = "zhaoyingjie1008@163.com" ' 发送者姓名 

JMail.MailServerUserName = "zhaoyingjie1008@163.com" ' 身份验证的用户名 

JMail.MailServerPassword = "12312312" ' 身份验证的密码 

'加入新的收件人 

JMail.AddRecipient cemail, cname 

'JMail.AddRecipientBCC Email '密件收件人的地址 

'JMail.AddRecipientCC Email '邮件抄送者的地址 

JMail.Subject = emailtitle 

JMail.Body = emailcontant 

'增加一个普通附件 

'JMail.AddAttachment(Server.MapPath()) 

'增加一个嵌入式附件 

' The return value of AddAttachment is used as a 

' reference to the image in the HTMLBody. 

'contentId = JMail.AddAttachment(Server.MapPath("images/email.gif")) 

'只有HTML格式支持嵌入图片附件,我们采用HTML格式的邮件内容 

' As only HTML formatted emails can contain inline images 

' we use HTMLBody and appendHTML 

JMail.HTMLBody = "<html><body><br>"&emailcontant 

JMail.appendHTML "<br><br></body></html>" 

'如果对方信箱不支持HTML格式邮件,我们仍需要给他一个友善的提示 

' But as not all mailreaders are capable of showing HTML emails 

' we will also add a standard text body 

JMail.Body = "Too bad you can't read HTML-mail." 

JMail.appendText " " 

if JMail.Send( "smtp.163.com" ) then '执行邮件发送(通过邮件服务器地址)smtp.域名.com 不一定是邮件服务器 

response.Write("OK") 

else 

response.Write("no") 

end if 

JMail.Close() 

Set JMail = Nothing 

%>


 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

若水印象

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值