【问题标题】:Error sending email from VBScript从 VBScript 发送电子邮件时出错
【发布时间】: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


    【解决方案1】:

    传输代码错误:0x80040217 根据具体情况可能有几种不同的情况。下面的链接应该会引导您朝着正确的方向前进...

    Overflowing Stack

    MSDN

    【讨论】:

    • 传奇,干杯!没有足够的声望来表示抱歉。
    【解决方案2】:

    我发现可能对此有所帮助的是,我想要使用此脚本的域有一个 SPF 记录,并附有硬故障,因此只有他们的特定电子邮件服务器才能使用此在我的情况下是 Office 365,但在测试时我使用他们的 ISP 并试图通过它们进行未经身份验证的中继。

    所以还要检查 SPF,希望这会有所帮助。

    温馨

    【讨论】:

      猜你喜欢
      • 2014-06-07
      • 2013-07-14
      • 1970-01-01
      • 2018-05-30
      相关资源
      最近更新 更多