Hello,

How do I get the quota of the account that I am currently connected to?

Thanks in advance!

asked 04 Mar '10, 13:19

Wakatake's gravatar image

Wakatake
384
accept rate: 0%

edited 04 Mar '10, 21:46

Martin%20Vobr's gravatar image

Martin Vobr ♦♦
335310


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 "GQTQUOTAROOT Inbox" command as shown above.

link

answered 04 Mar '10, 14:42

Lukas%20Pokorny's gravatar image

Lukas Pokorny ♦♦
2.2k18
accept rate: 32%

Thank you very much! It worked perfectly. I will just have to format the reply accordingly to what I need.

link

answered 04 Mar '10, 19:10

Wakatake's gravatar image

Wakatake
384
accept rate: 0%

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×71
×1

Asked: 04 Mar '10, 13:19

Seen: 1,251 times

Last updated: 04 Mar '10, 21:46