We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Get Imap mailbox size


I would need to recover the mailbox dimension of an Imap mailbox.
When I use the Pop3Client object I can use the GetMailboxSize function, but with the ImapClient object I can’t find any methods that return this value.

Is it possible to retrieve this value in some way?



Thank you for posting your inquiry.

You can use ImapClient.GetQuotaRoot(“Inbox”) method to get the same information. However, this needs to be supported by the server which can be checked by the QuotaSupported property as shown in the code sample below.

using (ImapClient client = TestUtil.CreateImapClient(user, true))
bool quotaSupported = client.QuotaSupported;
ImapQuotaRoot[] quotaRoots = client.GetQuotaRoot(“Inbox”);

I’m using this code:

If imap.QuotaSupported Then
Dim quotaRoots() As ImapQuotaRoot = imap.GetQuotaRoot(ImapFolderInfo.InBox)
Dim size As Integer = quotaRoots(0).Quotas(0).Used
End If

I check the size of the mailbox in webmail, and it seems that the size returned by the Used property is expressed in Kb. Is it correct? The GetMailboxSize function of the POP3 instead returns the size in byte. I need to convert the two different sizes in Mb so I should understand the format of each value.

Anyhow the GetQuotaRoot function seems to works fine but for some mailboxes I have an exception when I call the function GetQuotaRoot. The exception in a generic:

"Object reference not set to an instance of an object."

Unfortunately I don’t have a test mailbox on these servers so I can’t provide any information for testing. Are the some open tickets for the functionality?



We have tested this at our end and can verify that the Used and Limit properties are expresses in Kb. However, the API doesn’t change this and it is server side behavior that we have implemented as it is.

Regarding the exception you are facing, we have tested the behavior with Gmail server which supports this feature and were not able to face any exception or error. Moreover, there isn’t any such issue reported to us earlier as well. We would request you to please arrange a test account on your server for us where you are facing this issue and share its credentials here so that we can investigate it further at our end.