Xbase++ Requires Chilkat v11.0.0+
Xbase++
List IMAP Mailboxes
List the mailboxes available within an IMAP account.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oImap
LOCAL cRefName
LOCAL cWildcardedMailbox
LOCAL nSubscribed
LOCAL oMboxes
LOCAL i
nSuccess := 0
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oImap := CreateObject("Chilkat.Imap")
// Connect to an IMAP server.
// Use TLS
oImap:Ssl := 1
oImap:Port := 993
nSuccess := oImap:Connect("MY-IMAP-DOMAIN")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
// Login
nSuccess := oImap:Login("MY-IMAP-LOGIN", "MY-IMAP-PASSWORD")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
cRefName := ""
// refName is usually set to an empty string.
// A non-empty reference name argument is the name of a mailbox or a level of
// mailbox hierarchy, and indicates the context in which the mailbox
// name is interpreted.
// Select all mailboxes matching this pattern:
cWildcardedMailbox := "*"
nSubscribed := 0
oMboxes := CreateObject("Chilkat.Mailboxes")
nSuccess := oImap:MbxList(nSubscribed, cRefName, cWildcardedMailbox, oMboxes)
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
oMboxes:destroy()
RETURN
ENDIF
i := 0
DO WHILE i < oMboxes:Count
? oMboxes:GetName(i)
i := i + 1
ENDDO
// Sample output looks like this:
// INBOX.vendors.shareit
// INBOX.oldSupport
// INBOX.vendors.paypal
// INBOX.sales
// INBOX.lists
// INBOX.Drafts
// INBOX.vendors.dell
// INBOX.Trash
// INBOX.invoiceRequests
// INBOX.purchases
// INBOX.vendors.inMotion
// INBOX.oldEmail
// INBOX.vendors
// INBOX.lists.python
// INBOX.vendors.myhosting
// INBOX.Templates
// INBOX.friends
// INBOX.bounceSamples
// INBOX.lists.ruby
// INBOX.vendors.peer1
// INBOX.Sent
// INBOX.Junk
// INBOX
// Disconnect from the IMAP server.
nSuccess := oImap:Disconnect()
oImap:destroy()
oMboxes:destroy()