Sample code for 30+ languages & platforms
AutoIt

Save Email Attachments to Filesystem

Saves email attachments to a directory.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

$oEmail = ObjCreate("Chilkat.Email")

;  Load an email object containing attachments.
;  This .eml can be downloaded from:
;  http://www.example-code.com/testData/HtmlEmail.eml

$bSuccess = $oEmail.LoadEml("HtmlEmail.eml")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

;  If OverwriteExisting is turned on, files with the same
;  name are overwritten.  If turned off, new/unique filenames
;  are automatically generated.  The filenames actually saved
;  are accessible via the GetAttachmentFilename method.
$oEmail.OverwriteExisting = True

;  Save all attachments to the "myAttachments" subdirectory
;  found under the calling process's current working directory.
;  This directory is automatically created if it does not already
;  exist.
$bSuccess = $oEmail.SaveAllAttachments("myAttachments")
If ($bSuccess <> True) Then
    ConsoleWrite($oEmail.LastErrorText & @CRLF)
    Exit
EndIf

;  List the attachment filenames:
Local $i
For $i = 0 To $oEmail.NumAttachments - 1
    ConsoleWrite($oEmail.GetAttachmentFilename($i) & @CRLF)
Next