【问题标题】:Attaching multiple files while sending email through Autoit using python使用python通过Autoit发送电子邮件时附加多个文件
【发布时间】:2020-01-17 17:37:37
【问题描述】:

我正在尝试在 python 中使用 Autoit 函数进行自动化,但我无法弄清楚如何通过 Autoit 函数执行上传多个文件。

我的自动化包括单独发送一封电子邮件,其中附有图像文件。我发送的每封电子邮件的图像文件数量都会有所不同,我不确定如何执行相同的操作。由于 Autoit 需要附加文件的路径,在我的情况下,文件的名称和附件的数量每次都不同。

【问题讨论】:

    标签: python autoit


    【解决方案1】:

    看这里:Send an email with AutoIt

    在 Autoit 中,要发送带有多个附件的电子邮件,我使用 _InetSmtpMailCom() 函数,它使用 Microsoft CDO 方法。 CDO 的主要优点是它不依赖于您使用的客户端邮件程序。它只依赖于 SMTP 服务器。

    在这个UDF库中,你可以看到它如何处理附加多个文件ny解析参数s_AttachFiles

    在这个管理附件文件的库中的代码sn-p下面。

        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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-02-05
      • 2020-01-10
      • 1970-01-01
      • 2018-09-29
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多