MailBee.NET Objects 6.0

Imap.GetFolderQuota Method 

Gets the quota (resource usage limit) of the specified folder.

public FolderQuota GetFolderQuota(
   string folderName
);

Parameters

folderName
The full name of the folder to get the quota of.

Return Value

FolderQuota object if the quota information was downloaded successfully; otherwise, a null reference (Nothing in Visual Basic).

Remarks

This method can be used to obtain the folder quota information such as maximum allowed size of the folder, the current size of the folder, etc.

To get the quota set for the entire account on the IMAP4 server, the developer can use GetAccountQuota method.

Note    This method uses QUOTA capability be supported by the IMAP4 server. The developer can check if QUOTA capability is supported using GetExtension method.

Exceptions

Exception TypeCondition
MailBeeProtocolExtensionNotSupportedExceptionQUOTA not supported by the server and ThrowExceptions is true.
MailBeeExceptionAn error occurred and ThrowExceptions is true.

Example

This sample gets Inbox folder quota information and displays the maximum allowed size of the folder (the top limit of the total size in bytes of all messages in the folder).

[C#]
using System;
using MailBee;
using MailBee.ImapMail;
class Sample
{
    static void Main(string[] args)
    {
        Imap imp = new Imap();

        // Connect to the server and log in the account.
        imp.Connect("mail.company.com");
        imp.Login("jdoe@company.com", "secret");

        if (imp.GetExtension("QUOTA") != null)
        {
            // Download Inbox folder quota information.
            FolderQuota quota = imp.GetFolderQuota("Inbox");

            if (quota.MaxStorageSize > -1)
            {
                Console.WriteLine(quota.MaxStorageSize +
                    " is the maximum allowed total size (in bytes) " +
                    "of all messages in the folder.");
            }
        }
        else
        {
            Console.WriteLine("QUOTA capability not supported, sorry");
        }

        imp.Disconnect();
    }
}
[Visual Basic]
Imports System
Imports MailBee
Imports MailBee.ImapMail

Module Sample
    Sub Main(ByVal args As String())
        Dim imp As New Imap

        ' Connect to the server and log in the account.
        imp.Connect("imap4.company.com")
        imp.Login("jdoe@company.com", "secret")

        If Not imp.GetExtension("QUOTA") Is Nothing Then
            ' Download Inbox folder status information.
            Dim quota As FolderQuota = imp.GetFolderQuota("Inbox")

            If quota.MaxStorageSize > -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

Imap Class | MailBee.ImapMail Namespace | GetAccountQuota