【发布时间】:2017-09-14 14:32:15
【问题描述】:
我正在编写一个脚本,当它被写入某个文件夹时,它会自动发送一个 pdf 文件。 它几乎可以工作,但如果我有附件,我会收到语法错误 我将文件名作为常量放在代码中,它与附件一起使用。 但是,一旦我使用找到的文件的名称,它就不起作用。 这是我的代码。错误是“800401E4 CDO.Message.1”
FOLDER_PDF = "T:\MBö\AusdruckLieferverzug"
FOLDER_MOVE = "T:\MBö\AusdruckLieferverzug\Sent"
set lobj_cdomsg = CreateObject("CDO.Message")
Set objRegEx = CreateObject("VBScript.RegExp")
Set objFSO = CreateObject("Scripting.FileSystemObject")
strPDFs = ""
For Each file In objFSO.GetFolder(FOLDER_PDF).Files
If LCase(objFSO.GetExtensionName(file.Path)) = "pdf" Then
strPDFs = """" & file.Path & """"
End If
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "mail04.provider.de"
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "testperson@firma.de"
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "xxxxxx"
lobj_cdomsg.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465 '
lobj_cdomsg.To = "testperson@apt.de"
lobj_cdomsg.From = "testperson@apt.de"
lobj_cdomsg.Subject = "Lieferverzug"
lobj_cdomsg.TextBody = "Bitte finden Sie als Anlage eine PDF-Datei mit den Artikeln, die im Lieferverzug sind." & vbCRLF
strCmd = "lobj_cdomsg.AddAttachment " & strPDFs
WScript.Echo strCmd
lobj_cdomsg.AddAttachment strPDFs
'The following code works but not the code line before, although the content of strPDFs is exactly the same
'lobj_cdomsg.AddAttachment "T:\MBö\AusdruckLieferverzug\tesdatei.pdf"
'objFile.Close
' Dann ganzes abschicken
lobj_cdomsg.Configuration.Fields.Update
lobj_cdomsg.Send
Set lobj_cdomsg = Nothing
Next
你能帮我找出错误吗? 提前致谢
【问题讨论】:
标签: wsh