Click or drag to resize
MimeKit

MailFolderCount Property

Get the total number of messages in the folder.

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.7.1
Syntax
C#
public int Count { get; protected set; }

Property Value

Int32
The total number of messages.

Implements

IMailFolderCount
Remarks

Gets the total number of messages in the folder.

Note  Note
This value will only be set after calling Status(StatusItems, CancellationToken) with Count or by opening the folder.
Example
C#
public static void DownloadMessages ()
{
    using (var client = new ImapClient ()) {
        client.Connect ("imap.gmail.com", 993, SecureSocketOptions.SslOnConnect);

        client.Authenticate ("username", "password");

        client.Inbox.Open (FolderAccess.ReadOnly);

        for (int index = 0; index < client.Inbox.Count; index++) {
            var message = client.Inbox.GetMessage (index);

            // write the message to a file
            message.WriteTo (string.Format ("{0}.eml", index));
        }

        client.Disconnect (true);
    }
}
See Also