【问题标题】:Send email attachment发送电子邮件附件
【发布时间】:2017-03-24 18:00:59
【问题描述】:

我是 vbs 脚本的新手,但在这段代码中我无法发送附件。它发送电子邮件但没有附件 谁能帮忙

DIM fso
Set fso=CreateObject("Scripting.FilesystemObject")
On Error Resume Next
fso.CopyFile "C:\ASoft32\*.*", "E:\ASoft32\"
'Wscript.Echo "File copy complete."
strSMTPFrom = "jbmotors@hotmail.com"
strSMTPTo = "iain@252.co.uk"
strSMTPRelay = "smtp.live.com"
strTextBody = "Backup done vbs"
strSubject = "VBS ALERT"
strAddAttachment "(C:\ASoft32\Hamer.ftm)"
Set oMessage = CreateObject("CDO.Message")
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = strSMTPRelay
oMessage.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 
oMessage.Configuration.Fields.Update
oMessage.Subject = strSubject
oMessage.From = strSMTPFrom
oMessage.To = strSMTPTo
oMessage.TextBody = strTextBody
oMessage.AddAttachment  strADDAttachment
oMessage.Send
'Wscript.Echo "Email sent."
Const TIMEOUT = 2
Set objShell = WScript.CreateObject("WScript.Shell")
objShell.Popup "Email sent" , TIMEOUT

【问题讨论】:

    标签: windows vbscript


    【解决方案1】:

    您的代码中的strAddAttachment "(C:\ASoft32\Hamer.ftm)" 不起作用。

    试试:

    strAddAttachment = "C:\ASoft32\Hamer.ftm"

    假设文件存在于这个位置,那应该可以工作。

    【讨论】:

    • 我已经尝试过了,但没有成功,但如果我将 SMTP.live.com 更改为我的原始 SMTP 服务器,电子邮件会以一个空附件通过。
    • 我已经尝试过了,但没有成功,但是如果我将 SMTP.live.com 更改为我的原始 SMTP 服务器,电子邮件会以一个空附件通过。该脚本将在没有 Outlook 帐户的 PC 上运行,这些是它发送的电子邮件附件“Untitled Attachment 00212.dat (55B)
    猜你喜欢
    • 2016-11-30
    • 1970-01-01
    • 2021-03-06
    • 2020-06-24
    • 2015-08-28
    • 2015-06-19
    • 2019-03-04
    相关资源
    最近更新 更多