Sample code for 30+ languages & platforms
AutoIt

Test for an IMAP Server Capability

See more IMAP Examples

Demonstrates the Chilkat Imap.HasCapability method, which tests whether a named capability appears in a raw capability response. The second argument is typically the string returned by the Capability method. This example checks whether the server supports the IDLE extension.

Background: Rather than scanning the raw CAPABILITY text yourself, HasCapability parses it for a specific token. This is the right guard before using any optional feature — for example, only entering an IDLE wait loop, or using the MOVE command, when the server actually advertises it. Fetch the capability string once and test it as many times as needed.

Chilkat AutoIt Downloads

AutoIt
Local $bSuccess = False

;  Demonstrates the Imap.HasCapability method, which tests whether a named capability appears
;  in a raw capability response.  The 2nd argument is typically the string returned by the
;  Capability method.

$oImap = ObjCreate("Chilkat.Imap")

$oImap.Ssl = True
$oImap.Port = 993

$bSuccess = $oImap.Connect("imap.example.com")
If ($bSuccess = False) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf

;  Get the raw capability response.
Local $sCapabilities = $oImap.Capability()
If ($oImap.LastMethodSuccess = False) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf

;  Test whether the server supports the IDLE extension.
Local $bHasIdle = $oImap.HasCapability("IDLE",$sCapabilities)
If ($bHasIdle = True) Then
    ConsoleWrite("The server supports IDLE." & @CRLF)
Else
    ConsoleWrite("The server does not support IDLE." & @CRLF)
EndIf

$bSuccess = $oImap.Disconnect()
If ($bSuccess = False) Then
    ConsoleWrite($oImap.LastErrorText & @CRLF)
    Exit
EndIf