AutoIt
AutoIt
Download MIME Source of Emails in IMAP Mailbox
Demonstrates how to download the MIME source for emails on an IMAP server.Chilkat AutoIt Downloads
Local $bSuccess = False
; This example assumes the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
$oImap = ObjCreate("Chilkat.Imap")
; Connect to an IMAP server.
; Use TLS
$oImap.Ssl = True
$oImap.Port = 993
$bSuccess = $oImap.Connect("imap.example.com")
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
; Login
$bSuccess = $oImap.Login("myLogin","myPassword")
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
; Select an IMAP mailbox
$bSuccess = $oImap.SelectMailbox("Inbox")
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
; The NumMessages property contains the number of messages in the selected mailbox.
Local $iNumMessages = $oImap.NumMessages
If ($iNumMessages = 0) Then
ConsoleWrite("No messages exist in the Inbox." & @CRLF)
Exit
EndIf
$oSbMime = ObjCreate("Chilkat.StringBuilder")
Local $iSeqNum
For $iSeqNum = 1 To $iNumMessages
$oSbMime.Clear
$bSuccess = $oImap.FetchSingleAsMimeSb($iSeqNum,False,$oSbMime)
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
; The MIME source of the downloaded email is contained in sbMime.
Next
; Disconnect from the IMAP server.
$bSuccess = $oImap.Disconnect()