Sample code for 30+ languages & platforms
AutoIt

Add File Attachments to an Email

Demonstrates how to add one or more file attachments to an email.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oEmail = ObjCreate("Chilkat.Email")

$oEmail.Subject = "This is a test"
$oEmail.Body = "This is a test"
$oEmail.From = "support@chilkatsoft.com"
$bSuccess = $oEmail.AddTo("Chilkat Admin","admin@chilkatsoft.com")

; To add file attachments to an email, call AddFileAttachment
; once for each file to be attached.  The method returns
; the content-type of the attachment if successful, otherwise
; returns cknull
Local $sContentType

$sContentType = $oEmail.AddFileAttachment("something.pdf")
If ($oEmail.LastMethodSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$sContentType = $oEmail.AddFileAttachment("something.xml")
If ($oEmail.LastMethodSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$sContentType = $oEmail.AddFileAttachment("something.zip")
If ($oEmail.LastMethodSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oEmail.SaveEml("email.eml")
If ($bSuccess = False) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Saved EML!" & @CRLF)