Retrieves status information (total number of messages, various attributes as well as quota information) for the specified mailbox.

Namespace: S22.Imap
Assembly: S22.Imap (in S22.Imap.dll) Version: 3.6.0.0 (3.6.0.0)

Syntax

C#
MailboxInfo GetMailboxInfo(
	string mailbox = null
)

Parameters

mailbox (Optional)
Type: System..::..String
The mailbox to retrieve status information for. If this parameter is omitted, the value of the DefaultMailbox property is used to determine the mailbox to operate on.

Return Value

A MailboxInfo object containing status information for the mailbox.

Remarks

Not all IMAP servers support the retrieval of quota information. If it is not possible to retrieve this information, the UsedStorage and FreeStorage properties of the returned MailboxStatus instance are set to 0.

Examples

CopyC#
ImapClient Client = new ImapClient("imap.gmail.com", 993, "My_UsernamMe",
    "My_Password", true, AuthMethod.Login);

// Get a list of all mailboxes.
foreach(string m in Client.ListMailboxes())
{
    MailboxInfo info = Client.GetMailboxInfo(m);

    Console.WriteLine(info.Name);
    Console.WriteLine("Used storage: " + info.UsedStorage);
    Console.WriteLine("Free storage: " + info.FreeStorage);
    Console.WriteLine("Next UID: " + info.NextUID);
    Console.WriteLine("Messages: " + info.Messages);
    Console.WriteLine("Unread: " + info.Unread);
    Console.WriteLine("Set Flags: ");
    foreach (MailboxFlag f in info.Flags)
        Console.Write(f.ToString() + ",");
    Console.WriteLine();    
}

Client.Dispose();

Exceptions

ExceptionCondition
S22.Imap..::..BadServerResponseExceptionThe operation could not be completed because the server returned an error. The message property of the exception contains the error message returned by the server.
System..::..ObjectDisposedExceptionThe ImapClient object has been disposed.
System.IO..::..IOExceptionThere was a failure writing to or reading from the network.
S22.Imap..::..NotAuthenticatedExceptionThe method was called in non-authenticated state, i.e. before logging in.

See Also