Folder Flags

IMAP supports folder flags, which provide additional information about a folder, such as if it can be selected or if it has any subfolders. GemBox.Email exposes these flags as a read-only collection in the ImapFolderInfo class.

The example shows how to list folders and their flags using the GemBox.Email component.

Screenshot
Folder Flags Screenshot

See the full code below.

using GemBox.Email;
using GemBox.Email.Imap;
using GemBox.Email.Mime;
using GemBox.Email.Security;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Net.Security;
using System.Security.Cryptography.X509Certificates;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        using (ImapClient imap = new ImapClient("<ADDRESS> (e.g. imap.gmail.com)"))
        {
            imap.Connect();
            Console.WriteLine("Connected.");

            imap.Authenticate("<USERNAME>", "<PASSWORD>");
            Console.WriteLine("Authenticated.");

            // For this example we will use INBOX folder
            imap.SelectInbox();

            // List folder flags for INBOX
            IList<ImapFolderInfo> folders = imap.ListFolders();

            Console.WriteLine("Listing '{0}' folder flags...", imap.SelectedFolder.Name);

            foreach (string flag in imap.SelectedFolder.Flags)
                Console.WriteLine(flag);
        }
    }
}
Imports System.Globalization
Imports System.Net.Security
Imports System.Security.Cryptography.X509Certificates
Imports GemBox.Email
Imports GemBox.Email.Imap
Imports GemBox.Email.Mime

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        Using imap As New ImapClient("<ADDRESS> (e.g. imap.gmail.com)")

            imap.Connect()
            Console.WriteLine("Connected.")

            imap.Authenticate("<USERNAME>", "<PASSWORD>")
            Console.WriteLine("Authenticated.")

            ' For this example we will use INBOX folder
            imap.SelectInbox()

            ' List folder flags for INBOX
            Dim folders As IList(Of ImapFolderInfo) = imap.ListFolders()

            Console.WriteLine("Listing '{0}' folder flags...", imap.SelectedFolder.Name)

            For Each flag As String In imap.SelectedFolder.Flags
                Console.WriteLine(flag)
            Next

        End Using

    End Sub

End Module