微笑,关怀。。。

邮件无法发送到 SMTP 服务器。传输错误代码为 0x80040217

上一篇 / 下一篇  2009-12-07 17:21:32 / 个人分类:问题解决方案

  这个问题困惑了很久,网上找的答案都不能用,最后自己分析才解决,我用的163邮箱,原来163和qq都关闭了smtp服务器发送的功能,只有yahoo才能用

'邮件发送,参数依次是发送者姓名,收件者姓名,标题,内容,附件,密码

Function sendmail(sendUser,getUser,title,content,txtfile,pwd)   

 Dim userName       '用户名
NameSpace = "http://schemas.microsoft.com/cdo/configuration/"
Set Email = CreateObject("CDO.Message")
userName=Split(sendUser,"@")      '得到用户名
Email.From = sendUser      '发信人地址
Email.To = getUser           '收信人地址
Email.Subject = title          '邮件主题
Email.Textbody=content  '内容
Email.AddAttachment txtfile  '添加附件
with Email.Configuration.Fields
        .Item(NameSpace&"sendusing") = 2
        .Item(NameSpace&"smtpserver") = "smtp.mail.yahoo.com.cn" '这是yahoo邮箱的服务器地址
        .Item(NameSpace&"smtpserverport") = 25
        .Item(NameSpace&"smtpauthenticate") = 1
       .Item(NameSpace&"sendusername") = userName(0)'发信人用户名
        .Item(NameSpace&"sendpassword") = pwd '发信人密码
        .Update
End With
Email.Send
Set Email=Nothing
End Function
sendmail  "dfgf@yahoo.com.cn","dfdf@yahoo.com.cn","thisis me","hahahahha","d:\test11.txt","dfdfd"

 


TAG:

阳光之城 引用 删除 ljdfdd   /   2009-12-08 14:48:45
我只注册了个雅虎,gmail也行吧,没测过
前端测试工程师@淘宝 引用 删除 Eric_Lee   /   2009-12-08 13:45:08
用Gmail不是挺好的。。
前端测试工程师@淘宝 引用 删除 Eric_Lee   /   2009-12-08 13:45:01
用Gmail不是挺好的。。
 

评分:0

我来说两句

Open Toolbar