PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
li_Success = 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.
loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
destroy loo_Imap
MessageBox("Error","Connecting to COM object failed")
return
end if
loo_Imap.Ssl = 1
loo_Imap.Port = 993
li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// End the authenticated session.
li_Success = loo_Imap.Logout()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
// Close the connection.
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug "Logged out and disconnected."
destroy loo_Imap