Folder Flags

IMAP supports folder flags; they can provide you with additional information about a folder, such as if a folder is selected, if it has any subfolders, etc.

GemBox.Email represents each folder's flags with a read-only ImapFolderInfo.Flags collection. The possible flags that can occur are listed as an ImapFolderFlag enumeration.

The example shows how to list folders and their flags.

Screenshot of folder flags from ImapClient
Folder flags with IMAP client in C# and VB.NET
using System;
using System.Collections.Generic;
using GemBox.Email;
using GemBox.Email.Imap;

class Program
{
    static void Main()
    {
        // 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();
            imap.Authenticate("<USERNAME>", "<PASSWORD>");

            // Select INBOX folder.
            imap.SelectInbox();

            // List INBOX folder flags.
            IList<ImapFolderInfo> folders = imap.ListFolders();
            foreach (string flag in imap.SelectedFolder.Flags)
                Console.WriteLine(flag);
        }
    }
}
Imports System
Imports System.Collections.Generic
Imports GemBox.Email
Imports GemBox.Email.Imap

Module Program

    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()
            imap.Authenticate("<USERNAME>", "<PASSWORD>")

            ' Select INBOX folder.
            imap.SelectInbox()

            ' List INBOX folder flags.
            Dim folders As IList(Of ImapFolderInfo) = imap.ListFolders()
            For Each flag As String In imap.SelectedFolder.Flags
                Console.WriteLine(flag)
            Next
        End Using
    End Sub
End Module

For more information about ImapClient, check out our IMAP Client Connection example.

Check next example or download examples from GitHub.