ImapDownloadFolders Method (Boolean)
Downloads the list of IMAP folders of the mail account.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 11.2.0 build 590 for .NET 4.5
Syntax
public FolderCollection DownloadFolders(
	bool subscribedOnly
)

Parameters

subscribedOnly
Type: SystemBoolean
If true, only subscribed folders will be downloaded; otherwise, all the folders.

Return Value

Type: FolderCollection
FolderCollection object if the folder list was downloaded successfully; otherwise, a null reference (Nothing in Visual Basic).
Exceptions
ExceptionCondition
MailBeeExceptionAn error occurred and ThrowExceptions is true.
Remarks
If subscribedOnly is false, UseXList is true and the server supports XLIST extension, extended folder flags like Drafts or Trash will be available. See UseXList topic for details.
Note Note
If the server supports SPECIAL-USE IMAP extension (Gmail does), extended flags will be available in all modes (both "list all folders" and "list subscribed-only folders"), even if UseXList is disabled.
Examples
This sample downloads the list of all subscribed folders of the mail account, and displays their full names.
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();
    }
}
See Also