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.

Folder flags with IMAP client in C# and VB.NET
Screenshot of folder flags from ImapClient
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.

        using (ImapClient imap = new ImapClient("<ADDRESS> (e.g."))
            imap.Authenticate("<USERNAME>", "<PASSWORD>");

            // Select INBOX folder.

            // List INBOX folder flags.
            IList<ImapFolderInfo> folders = imap.ListFolders();
            foreach (string flag in imap.SelectedFolder.Flags)
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.

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

            imap.Authenticate("<USERNAME>", "<PASSWORD>")

            ' Select INBOX folder.

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

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

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.

Like it?

Download Buy

If you want to try the GemBox.Email yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.