DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
Boolean iLoggedIn
String sTemp1
Move False To iSuccess
// 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.
Get Create (RefClass(cComChilkatImap)) To hoImap
If (Not(IsComObjectCreated(hoImap))) Begin
Send CreateComObject of hoImap
End
Set ComSsl Of hoImap To True
Set ComPort Of hoImap To 993
Get ComConnect Of hoImap "imap.example.com" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Check whether the session is authenticated.
Get ComIsLoggedIn Of hoImap To iLoggedIn
If (iLoggedIn = True) Begin
Showln "The session is authenticated."
End
Else Begin
Showln "The session is not authenticated."
End
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure