Visual FoxPro
Visual FoxPro
Select an IMAP Mailbox
See more IMAP Examples
Demonstrates the Chilkat Imap.SelectMailbox method, which opens a mailbox for read-write access. A mailbox must be selected before message fetch, search, flag, copy, move, or expunge operations that act on messages. This example selects the Inbox.
Background: In IMAP, mail is organized into mailboxes (folders), and most message operations act on the currently selected one — so selecting a mailbox is the required step between logging in and working with messages.
SelectMailbox opens it read-write, allowing changes such as setting flags or deleting. When you only need to read and must not alter anything (including the \Seen flag), use ExamineMailbox instead.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loImap
lnSuccess = 0
* Demonstrates the Imap.SelectMailbox method, which opens a mailbox for read-write access.
* A mailbox must be selected before message fetch, search, flag, copy, move, or expunge
* operations that act on messages.
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
* Open the Inbox for read-write access.
lnSuccess = loImap.SelectMailbox("Inbox")
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
? "Inbox selected for read-write access."
lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
? loImap.LastErrorText
RELEASE loImap
CANCEL
ENDIF
RELEASE loImap