Downloads the list of IMAP folders of the mail account.
FolderCollection object if the folder list was downloaded successfully; otherwise, a null reference (Nothing in Visual Basic).
| Exception Type | Condition |
|---|---|
| MailBeeException | An error occurred and ThrowExceptions is true. |
This sample downloads the list of all subscribed folders of the mail account, and displays their full names.
[C#] using System; using MailBee; using MailBee.ImapMail; class Sample { static void Main(string[] args) { Imap imp = new Imap(); // Connect to the server and log in the account. imp.Connect("mail.company.com"); imp.Login("jdoe@company.com", "secret"); // Download only subscribed folders. FolderCollection folders = imp.DownloadFolders(true); // Print full names of the folders. foreach (Folder fold in folders) { Console.WriteLine(fold.Name); } imp.Disconnect(); } }
[Visual Basic] Imports System Imports MailBee Imports MailBee.ImapMail Module Sample Sub Main() Dim imp As New Imap ' Connect to the server and log in the account. imp.Connect("imap4.company.com") imp.Login("jdoe@company.com", "secret") ' Download only subscribed folders. Dim folders As FolderCollection = imp.DownloadFolders(True) ' Print full names of the folders. For Each fold As Folder In folders Console.WriteLine(fold.Name) Next imp.Disconnect() End Sub End Module
Imap Class | MailBee.ImapMail Namespace | Imap.DownloadFolders Overload List | BeginDownloadFolders