2017-03-23 68 views
0

我是vbs脚本的新手,但在此代码中,我无法获取要发送的附件。它发出的电子邮件,但没有附件 谁能帮发送电子邮件附件

DIM fso 
Set fso=CreateObject("Scripting.FilesystemObject") 
On Error Resume Next 
fso.CopyFile "C:\ASoft32\*.*", "E:\ASoft32\" 
'Wscript.Echo "File copy complete." 
strSMTPFrom = "[email protected]" 
strSMTPTo = "[email protected]" 
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 

回答

0

在你的代码strAddAttachment "(C:\ASoft32\Hamer.ftm)"将无法​​正常工作。

尝试:

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

假设文件在此位置存在,应该工作。

+0

我试过了,但没有成功,但如果我将SMTP.live.com更改为我的处女SMTP服务器,则电子邮件会通过一个空的附件。 –

+0

我试过了,没有成功,但如果我将SMTP.live.com更改为我的处女SMTP服务器,则电子邮件会通过一个空的附件。该脚本将在Outlook中没有帐户的PC上运行,这是它发送的电子邮件附件“无标题附件00212.dat(55B) –