AutoIt
AutoIt
Check Whether the IMAP Session Is Authenticated
See more IMAP Examples
Demonstrates the Chilkat Imap.IsLoggedIn method, which indicates whether this object is in an authenticated IMAP session. It reports the last known state and does not send a command to the server. This example connects, logs in, and checks the state.
Background: An IMAP session has two levels: connected (the TCP/TLS link is up) and authenticated (login succeeded).
IsLoggedIn reports the second — useful when reusing a long-lived Imap object to decide whether you still need to log in before performing mailbox operations. Like IsConnected, it reflects cached state and doesn't contact the server.Chilkat AutoIt Downloads
Local $bSuccess = False
; Demonstrates the Imap.IsLoggedIn method, which indicates whether this object is in an
; authenticated IMAP session. It reports the last known state and does not send a command
; to the server.
$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
; Check whether the session is authenticated.
Local $bLoggedIn = $oImap.IsLoggedIn()
If ($bLoggedIn = True) Then
ConsoleWrite("The session is authenticated." & @CRLF)
Else
ConsoleWrite("The session is not authenticated." & @CRLF)
EndIf
$bSuccess = $oImap.Disconnect()
If ($bSuccess = False) Then
ConsoleWrite($oImap.LastErrorText & @CRLF)
Exit
EndIf