Visual FoxPro
Visual FoxPro
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 Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loImap
lnSuccess = 0
* Demonstrates the Imap.CloseMailbox method, which closes the currently selected mailbox
* while keeping the authenticated IMAP connection open.
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
* Select a mailbox and work with its messages.
lnSuccess = loImap.SelectMailbox("Inbox")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
* Close the selected mailbox (the connection stays open and authenticated).
lnSuccess = loImap.CloseMailbox("Inbox")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
? "Mailbox closed; still connected."
lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
RELEASE loImap