Sample code for 30+ languages & platforms
AutoIt

Connecting to GMAIL using IMAP

Demonstrates how to connect to GMAIL using IMAP.

Chilkat AutoIt Downloads

AutoIt
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")

; Turn on session logging:
$oImap.KeepSessionLog = True

; Connect to GMail
; Use TLS
$oImap.Ssl = True
$oImap.Port = 993
$bSuccess = $oImap.Connect("imap.gmail.com")
If ($bSuccess <> True) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf

; Login
; Your login is typically your GMail email address.
$bSuccess = $oImap.Login("username@gmail.com","myPassword")
If ($bSuccess <> True) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf

; Select an IMAP mailbox
$bSuccess = $oImap.SelectMailbox("Inbox")
If ($bSuccess <> True) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf

; Show the session log.
ConsoleWrite($oImap.SessionLog & @CRLF)

; Disconnect from the IMAP server.
$bSuccess = $oImap.Disconnect()