Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap
LOCAL lnLoggedIn

lnSuccess = 0

*  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.

loImap = CreateObject('Chilkat.Imap')

loImap.Ssl = 1
loImap.Port = 993

lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

lnSuccess = loImap.Login("user@example.com","myPassword")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

*  Check whether the session is authenticated.
lnLoggedIn = loImap.IsLoggedIn()
IF (lnLoggedIn = 1) THEN
    ? "The session is authenticated."
ELSE
    ? "The session is not authenticated."
ENDIF

lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

RELEASE loImap