ImapDownloadFolders Method
Downloads the list of all IMAP folders of the mail account.

Namespace: MailBee.ImapMail
Assembly: MailBee.NET (in MailBee.NET.dll) Version: 12.2.0 build 630 for .NET 4.5
public FolderCollection DownloadFolders()

Return Value

Type: FolderCollection
FolderCollection object if the folder list was downloaded successfully; otherwise, a null reference (Nothing in Visual Basic).
MailBeeExceptionAn error occurred and ThrowExceptions is true.
If the server supports XLIST or SPECIAL-USE extensions (Gmail does), well-known folder flags like Drafts or Trash will be available. See UseXList topic for details.
This sample downloads the list of all folders of the mail account, and displays them with in user-friendly view with indentation of folder nesting levels.
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.Login("jdoe", "secret");

        // Download all the folders.
        FolderCollection folders = imp.DownloadFolders();

        // Used for indentation of folder levels in the output.
        System.Text.StringBuilder sb = new System.Text.StringBuilder();

        foreach (Folder fold in folders)
            // Indent each nesting level with two space characters.
            sb.Length = 0;
            sb.Append(' ', fold.NestingLevel * 2);

            // Print formatted name of the folder.
            Console.WriteLine(sb.ToString() + fold.ShortName);

See Also