[英]Attaching multiple files while sending email through Autoit using python
我正在嘗試在 python 中使用 Autoit 函數進行自動化,但我無法弄清楚如何通過 Autoit 函數執行上傳多個文件。
我的自動化包括單獨發送帶有圖像文件的電子郵件。 圖像文件的數量會因我發送的每封電子郵件而異,我不確定如何執行。 由於 Autoit 需要附加文件的路徑,在我的情況下,文件名和附件數量每次都不同。
看這里: 使用 AutoIt 發送電子郵件
在 Autoit 中,要發送帶有多個附加文件的電子郵件,我使用_InetSmtpMailCom()
函數,它使用 Microsoft CDO 方法。 CDO 的主要優勢在於它不依賴於您使用的客戶端郵件程序。 它只依賴於 SMTP 服務器。
在這個 UDF 庫中,您可以看到它如何處理附加多個文件 ny 解析參數s_AttachFiles
在此庫中管理附件文件的代碼片段下方。
If $s_AttachFiles <> "" Then
Local $S_Files2Attach = StringSplit($s_AttachFiles, ";")
For $x = 1 To $S_Files2Attach[0]
$S_Files2Attach[$x] = _PathFull ($S_Files2Attach[$x])
If FileExists($S_Files2Attach[$x]) Then
$objEmail.AddAttachment ($S_Files2Attach[$x])
Else
$i_Error_desciption = $i_Error_desciption & @lf & 'File not found to attach: ' & $S_Files2Attach[$x]
SetError(1)
return 0
EndIf
Next
EndIf
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.