You can use Imap
object's SendCommand
/ReadResonse
methods to achieve this if your IMAP server supports quotas:
// initialize a connection
Imap imap = new Imap();
imap.Connect("imap.gmail.com", 993, null, ImapSecurity.Implicit);
imap.Login(email, password);
// determine Inbox quotas
imap.SendCommand("GETQUOTAROOT", "Inbox");
ImapResponse response = imap.ReadResponse();
// display Inbox quotas returned by the server
foreach (ImapResponseLine line in response.GetLines())
{
if (line.Code == "QUOTA")
{
// Format: quote_root_name (resource_name current_usage limit)
// Sample: "" (STORAGE 546615 7599416)
Console.WriteLine(line.Parameters);
}
}
Please be aware that quotas in IMAP are quite complex (see RFC 2087 for details): Each folder has zero or more implementation-defined named "quota roots". Each quota root has zero or more resource limits. All folders that share the same named quota root share the resource limits of the quota root.
However, many IMAP servers (such as Gmail) only have a single "quota root" shared by all folders, which makes it possible to determine all information about it using a single "GETQUOTAROOT Inbox" command as shown above.