0
我正在寫一個腳本tp自動發送一個pdf文件,當它已經wroten進入某個文件夾。 它幾乎工作,但如果我有一個附件,我得到一個語法錯誤 它我把文件的名稱作爲常量在代碼中,它與附件一起工作。 但是,只要我找到找到的文件的名稱,它不起作用。 這是我的代碼。錯誤是「800401E4 CDO.Message.1」WSH腳本中的語法錯誤
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") = "[email protected]"
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 = "[email protected]"
lobj_cdomsg.From = "[email protected]"
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
你能幫我找到錯誤嗎? 在此先感謝
[CDO.Message.1 error'80040220'](https://stackoverflow.com/questions/33391500/cdo-message-1-error-80040220)可能的重複 –