Sample code for 30+ languages & platforms
AutoIt

Read All Email from POP3 Inbox by Message Numbers

Demonstrates how to read all of the email from a POP3 inbox by fetching each email by it's message number.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.

$oMailman = ObjCreate("Chilkat.MailMan")

; Set the POP3 server's hostname
$oMailman.MailHost = "pop.example.com"

; Set the POP3 login/password.
$oMailman.PopUsername = "myLogin"
$oMailman.PopPassword = "myPassword"

; Get the number of messages in the mailbox.
Local $iNumMessages = $oMailman.GetMailboxCount()

; Message numbers are specific to a POP3 session. 
; If a maildrop (i.e. inbox)  contains 10 messages, 
; the message numbers will be 1, 2, 3, ... 10. 
; If message number 1 is deleted and a new POP3 session 
; is established, there will be 9 messages numbered 1, 2, 3, ... 9. 

Local $i = 1

$oEmail = ObjCreate("Chilkat.Email")
While $i <= $iNumMessages
    ; Fetch by the message number (not by the UIDL)
    $bSuccess = $oMailman.FetchOne(False,0,$i,$oEmail)
    If ($bSuccess = False) Then
        ConsoleWrite($oMailman.LastErrorText & @CRLF)
        Exit
    EndIf

    ConsoleWrite($oEmail.From & ": " & $oEmail.Subject & @LF & @CRLF)

    $i = $i + 1
Wend