【发布时间】:2017-02-20 10:13:04
【问题描述】:
运行以下脚本时,我收到错误 -2147220975 和传输代码错误:0x80040217
on error resume next
Const schema = "http://schemas.microsoft.com/cdo/configuration/"
Const cdoBasic = 1
Const cdoSendUsingPort = 2
Dim oMsg, oConf
Set oMsg = CreateObject("CDO.Message")
oMsg.From = "tom.watt.vulpes@gmail.com"
oMsg.To = "tom.watt.vulpes@gmail.com"
oMsg.Subject = "Test from VBScript"
oMsg.TextBody = "If you can read this, the script worked!"
objMsg.AddAttachment "C:\BLA_BLA.txt"
Set oConf = oMsg.Configuration
oConf.Fields(schema & "smtpserver") = "smtp.gmail.com"
oConf.Fields(schema & "smtpserverport") = 465
oConf.Fields(schema & "sendusing") = cdoSendUsingPort
oConf.Fields(schema & "smtpauthenticate") = cdoBasic
oConf.Fields(schema & "smtpusessl") = True
oConf.Fields(schema & "sendusername") = "tom.watt.vulpes@gmail.com"
oConf.Fields(schema & "sendpassword") = "PASSWORD"
oConf.Fields.Update()
oMsg.Send()
If Err Then
resultMessage = "ERROR " & Err.Number & ": " & Err.Description
Err.Clear()
Else
resultMessage = "Message sent ok"
End If
Wscript.echo(resultMessage)
我尝试了无数来自互联网的脚本,但似乎没有一个可以工作。我究竟做错了什么? 谢谢,汤姆
编辑:我正在运行 Windows 10
【问题讨论】:
标签: email vbscript email-attachments