RetrieveMailboxesEx Method


This method retrieves Mailboxes collection which contains mailboxes of the IMAP4 account. This collection includes only mailboxes which are passed user defined criteria.

See example in GetCapabilities topic on how to get all the folders with special folder flags (e.g. Sent or Drafts). Special folder flags will be available together with all other folder flags through Mailbox.Flags property of each Mailbox object in the returned collection.

Note: to get special folder flags, you must use the IMAP4 server which supports XLIST extension. For instance, GMail does support this extension.


objMailboxes = ObjectName.RetrieveMailboxes(RootMailBoxName, [SubscribedOnly], OneLevelOnly, [GetSpecialFoldersFlags])  
Parameters:  
RootMailboxName As String (optional) If not empty only sub-folders of the specified mailbox will be retrieved, otherwise all folders of the account will be retrieved. Default is False meaning that no folder filter is set.  
SubscribedOnly As Boolean (optional) If True the only subscribed mailboxes will be retrieved (the parameter is ignored if GetSpecialFoldersFlags is True). Default is False  
OneLevelOnly (optional) If True only first level sub-folders of the mailbox will be retrieved. Default is False  
GetSpecialFoldersFlags As Boolean (optional) If True, MailBee will also determine special folder flags (Inbox/Drafts/Sent/Spam/Trash) by using XLIST command instead of LIST (the server must support XLIST). The default is False  
Return value As MailBee.Mailboxes On success, Mailboxes collection is returned. On failure, return value is Nothing  

Usage example:

' This sample gets first-level mailboxes list and selects last mailbox in the collection.
' Then, number of messages is displayed for this mailbox. 
Dim Mailer, Mailboxes
' Using visual basic to create object
Set Mailer = CreateObject("MailBee.IMAP4")
' Using ASP to create object
' Set Mailer = Server.CreateObject("MailBee.IMAP4")
' In ASP use Response.Write instead of MsgBox
Mailer.EnableLogging = True
Mailer.LogFilePath = "C:\imap4_log.txt"
Mailer.ClearLog
Mailer.LicenseKey = "put your license key"
If Mailer.Connect("mailserver.com", 143, "MyName", "MyPassword") Then
   Set Mailboxes = Mailer.RetrieveMailboxesEx("", False, True)
   If Not Mailboxes Is Nothing Then
      If (Mailboxes.Count > 0) Then
         If Mailer.SelectMailbox(Mailboxes(Mailboxes.Count).Name) Then
            MsgBox Mailer.MessageCount & " messages in " & Mailboxes(Mailboxes.Count).Name
         End If
      End If
   End If
   Mailer.Disconnect
End If

See Also:

RetrieveMailboxes Method | ExamineMailbox Method | SelectMailbox Method | Mailbox Object | Mailboxes Collection


Copyright 2002-2013, AfterLogic Corporation. All rights reserved.