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  林岳  阅读(6062)  评论(2编辑  收藏  举报