随笔-12  评论-90  文章-1  trackbacks-5

ASP下使用CDO.Message实现需要身份验证的邮件发送


 Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject ("CDO.Configuration")
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.mail.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "username"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "password"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/languagecode") = "0x0804"
objConfig.Fields.Update()
Set objMail.Configuration = objConfig
objMail.Subject = "Mail Subject"
objMail.From = chr(34) & "姓名" & chr(34) & "username@mail.com"
objMail.To = "gbhglxs@customs.gov.cn"
objMail.HTMLBody = "Mail Body"
objMail.AddAttachment(http://xxxxxx/xxxx.xxx) '或者其他任何正确的url,包括http,ftp,file等等。
objMail.Send
Response.Write "邮件发送成功!"
最值得注意的是:sendusername要和From相一致。
posted on 2006-11-22 23:08 林岳 阅读(3511) 评论(2) 编辑 收藏

评论:
#1楼 2007-04-10 14:33 | pingkuan[未注册用户]
Set objMail = Server.CreateObject("CDO.Message")
Set objConfig = Server.CreateObject ("CDO.Configuration")
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail.zzvcom.com"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "pingkuan"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "123456"
objConfig.Fields("http://schemas.microsoft.com/cdo/configuration/languagecode") = "0x0804"
objConfig.Fields.Update()
Set objMail.Configuration = objConfig
objMail.Subject = "Mail Subject"
objMail.From = chr(34) & "姓名" & chr(34) & "pingkuan@zzvcom.com"
objMail.To = "pingkuan2@163.com"
objMail.HTMLBody = "Mail Body"
objMail.AddAttachment("http://www.ybb258.cn") '或者其他任何正确的url,包括http,ftp,file等等。
objMail.Send
Response.Write "邮件发送成功!"

----------------------------------------------------------------

错误 '80040211'
/user/emailtest.asp,行 26
-------------------------------------------------------------
QQ 8192198 请帮忙看看


 回复 引用   
#2楼 2008-07-25 10:37 | jameswilliam[未注册用户]
用这个方法发不出,老提示错误:“An error occurred: The transport failed to connect to the server”
什么问题?

 回复 引用   
昵称:林岳
园龄:5年11个月
粉丝:0
关注:0
<2006年11月>
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789

搜索

 
 

常用链接

随笔档案

相册

最新评论

阅读排行榜

评论排行榜

推荐排行榜