Xbase++
Xbase++
Log Out of an IMAP Server
See more IMAP Examples
Demonstrates the Chilkat Imap.Logout method, which sends the IMAP LOGOUT command and ends the authenticated session. The server normally closes the connection as part of a successful logout. This example connects, logs in, logs out, and disconnects.
Background:
LOGOUT is the polite way to end an IMAP session — it tells the server you are finished so it can release the session's resources and close the socket gracefully, rather than treating the disconnect as an abrupt drop. It is the counterpart to Login; calling Disconnect afterward ensures the local socket is fully closed.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oImap
nSuccess := 0
// Demonstrates the Imap.Logout method, which sends the IMAP LOGOUT command and ends the
// authenticated session. The server normally closes the connection as part of a successful
// logout.
oImap := CreateObject("Chilkat.Imap")
oImap:Ssl := 1
oImap:Port := 993
nSuccess := oImap:Connect("imap.example.com")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
nSuccess := oImap:Login("user@example.com", "myPassword")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
// End the authenticated session.
nSuccess := oImap:Logout()
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
// Close the connection.
nSuccess := oImap:Disconnect()
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
? "Logged out and disconnected."
oImap:destroy()