1

I am trying to use Autoit function in python for automation and I'm unable to figure out how to execute uploading multiple files through Autoit function.

My automation includes sending an email individually with image files attached to the email. The count of image file will vary for every email I send and I am unsure how to execute the same. Since Autoit requires the path of the file to be attached and in my case the name of the file and the count of attachments varies each time.

SecretAgentMan
  • 2,856
  • 7
  • 21
  • 41
Srini Vasan
  • 83
  • 1
  • 1
  • 7

1 Answers1

0

Take a look here : Send an email with AutoIt

In Autoit, to send emails with multiple attaching files i use _InetSmtpMailCom() function, wich it consumes Microsoft CDO method. The principle advantage of CDO, is it doesn't depend of client mail program you use. It's only depend on SMTP server.

In this UDF library, you can see how it handles to attach multiple file ny parsing the parameter s_AttachFiles

Below the code snippet in this library which manages attachments file.

    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
v20100v
  • 696
  • 4
  • 11