AutoIt
AutoIt
End IMAP IDLE Mode
See more IMAP Examples
Demonstrates the Chilkat Imap.IdleDone method, which ends IDLE mode by sending the protocol's DONE continuation. It takes no arguments. The authenticated connection remains open and usable afterward.
Background: While IDLE is active the connection is dedicated to receiving push notifications, so any command that needs to talk to the server — fetching a message, setting a flag — must wait until IDLE ends.
IdleDone cleanly exits IDLE without dropping the login, so the same connection can immediately be reused. Calling it when IDLE is not active fails.Chilkat AutoIt Downloads
Local $bSuccess = False
; Demonstrates the Imap.IdleDone method, which ends IMAP IDLE mode by sending the DONE
; continuation. It takes no arguments. The authenticated connection remains open and usable.
$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
$bSuccess = $oImap.Login("user@example.com","myPassword")
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oImap.SelectMailbox("Inbox")
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
$bSuccess = $oImap.IdleStart()
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
; Check once for any updates that arrived.
Local $iTimeoutMs = 5000
Local $sUpdates = $oImap.IdleCheck($iTimeoutMs)
If ($oImap.LastMethodSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite($sUpdates & @CRLF)
; End IDLE so that ordinary IMAP commands can be sent again on the same connection.
$bSuccess = $oImap.IdleDone()
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("IDLE mode ended." & @CRLF)
$bSuccess = $oImap.Disconnect()
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf