ImapGetAccountQuota Method |
Gets the quota (resource usage limit) of the entire mail account on the server.
Namespace: MailBee.ImapMailAssembly: MailBee.NET (in MailBee.NET.dll) Version: 12.5.0 build 687 for .NET 4.5
Syntax public FolderQuota GetAccountQuota()
Public Function GetAccountQuota As FolderQuota
Return Value
Type:
FolderQuotaFolderQuota object if the quota information was downloaded successfully; otherwise, a null reference (
Nothing in Visual Basic).
Exceptions Remarks
This method can be used to obtain the account quota and current usage (in bytes). Also, the current and the maximum number of messages
in the account can be set too. However, most servers limit account usage in bytes only. Number of messages is usually not limited and not counted.
Note |
---|
This method uses QUOTA capability be supported by the IMAP4 server. The developer can check if QUOTA capability is supported
using GetExtension(String) method. Also, some servers cannot return an account quota but they can return it for INBOX folder (however, this in fact designates
the quota for the entire account). If you got such a server, use GetFolderQuota("INBOX") instead of GetAccountQuota.
|
Examples This sample gets the account quota information and displays the maximum size (in bytes) and
the current usage (in percent) of the account storage.
using System;
using MailBee;
using MailBee.ImapMail;
class Sample
{
static void Main(string[] args)
{
Imap imp = new Imap();
imp.Connect("imap.company.com");
imp.Login("jdoe", "secret");
if (imp.GetExtension("QUOTA") != null)
{
FolderQuota quota = imp.GetAccountQuota();
if (quota.MaxStorageSize > -1 && quota.CurrentStorageSize > -1)
{
long percent = (quota.CurrentStorageSize * 100) / quota.MaxStorageSize;
Console.WriteLine("You are using " + percent.ToString() + "% of your " +
quota.MaxStorageSize + " space");
}
}
else
{
Console.WriteLine("QUOTA capability not supported, sorry");
}
imp.Disconnect();
}
}
Imports System
Imports MailBee
Imports MailBee.ImapMail
Module Sample
Sub Main(ByVal args As String())
Dim imp As New Imap
imp.Connect("imap4.company.com")
imp.Login("jdoe@company.com", "secret")
If Not imp.GetExtension("QUOTA") Is Nothing Then
Dim quota As FolderQuota = imp.GetAccountQuota()
If quota.MaxStorageSize > -1 AndAlso quota.CurrentStorageSize > -1 Then
Console.WriteLine(quota.MaxStorageSize & _
" is the maximum allowed total size (in bytes) " & _
"of all messages in the folder.")
End If
Else
Console.WriteLine("QUOTA capability not supported, sorry")
End If
imp.Disconnect()
End Sub
End Module
See Also