DataFlex
DataFlex
Close the Selected IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.CloseMailbox method, which closes the currently selected mailbox while keeping the authenticated IMAP connection open. This example selects the Inbox and then closes it. (The mailbox-name argument is retained for backward compatibility but is ignored.)
Background: IMAP's
CLOSE command returns the session to the "authenticated but no mailbox selected" state without logging out — so you can move on to another mailbox on the same connection. As a side effect, CLOSE also silently expunges \Deleted messages. When you want to switch mailboxes but not expunge, simply select the next mailbox instead of closing.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoImap
String sTemp1
Move False To iSuccess
// Demonstrates the Imap.CloseMailbox method, which closes the currently selected mailbox
// while keeping the authenticated IMAP connection open.
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
// Select a mailbox and work with its messages.
Get ComSelectMailbox Of hoImap "Inbox" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
// Close the selected mailbox (the connection stays open and authenticated).
Get ComCloseMailbox Of hoImap "Inbox" To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Mailbox closed; still connected."
Get ComDisconnect Of hoImap To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoImap To sTemp1
Showln sTemp1
Procedure_Return
End
End_Procedure