Click or drag to resize
MimeKit

IMailFolderCount Property

Get the total number of messages in the folder.

Namespace: MailKit
Assembly: MailKit (in MailKit.dll) Version: 4.3.0
Syntax
C#
int Count { get; }

Property Value

Int32
The total number of messages.
Remarks
Gets the total number of messages in 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