smtp无法获取服务器上的邮件,邮件无法发送到 SMTP 服务器。传输错误代码为 0x80040217...

这个问题困惑了很久,网上找的答案都不能用,最后自己分析才解决,我用的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"

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值