MailBee.NET Objects 4.0

Imap.DownloadFolders Method (Boolean)

Downloads the list of IMAP folders of the mail account.

public FolderCollection DownloadFolders(
   bool subscribedOnly
);

Parameters

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

Return Value

FolderCollection object if the folder list was downloaded successfully; otherwise, a null reference (Nothing in Visual Basic).

Exceptions

Exception Type Condition
MailBeeException An error occurred and ThrowExceptions is true.

Example

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

See Also

Imap Class | MailBee.ImapMail Namespace | Imap.DownloadFolders Overload List | BeginDownloadFolders