Xbase++
Xbase++
Disconnect from an IMAP Server
See more IMAP Examples
Demonstrates the Chilkat Imap.Disconnect method, which closes the connection to the IMAP server. A failure indicates the connection could not be closed cleanly; the socket is nevertheless no longer intended for use. This example connects, logs in, and then disconnects.
Background:
Disconnect closes the underlying TCP socket. It is lower-level than Logout, which first tells the server to end the IMAP session; the tidy shutdown is Logout followed by Disconnect. Always releasing connections matters because servers cap the number of simultaneous IMAP connections per account, and leaked connections can lock you out until they time out.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oImap
nSuccess := 0
// Demonstrates the Imap.Disconnect method, which closes the connection to the IMAP server.
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
// ... perform mailbox operations here ...
// Close the connection to the IMAP server.
nSuccess := oImap:Disconnect()
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
? "Disconnected from the IMAP server."
oImap:destroy()