Sample code for 30+ languages & platforms
DataFlex

Get an IMAP Mailbox Quota

See more IMAP Examples

Demonstrates the Chilkat Imap.GetQuota method, which sends the IMAP GETQUOTA command for a quota root and returns the server response as JSON. The server must advertise the IMAP QUOTA extension. This example queries the default quota root.

Tip: JSON parsing code for this result can be generated at Chilkat Tools.

Background: Mail servers often cap how much storage an account may use. The IMAP QUOTA extension reports the current usage and limit for a quota root — a scope that may cover one mailbox or a whole account. Reading it lets an application warn a user who is nearing their limit, or refuse to append large messages that would exceed it. Check HasCapability for QUOTA first, since not all servers support it.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoImap
    String sQuotaJson
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    //  Demonstrates the Imap.GetQuota method, which sends the IMAP GETQUOTA command for a quota
    //  root and returns the server response as JSON.  The server must advertise the IMAP QUOTA
    //  extension.

    Get Create (RefClass(cComChilkatImap)) To hoImap
    If (Not(IsComObjectCreated(hoImap))) Begin
        Send CreateComObject of hoImap
    End

    Set ComSsl Of hoImap To True
    Set ComPort Of hoImap To 993

    Get ComConnect Of hoImap "imap.example.com" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComLogin Of hoImap "user@example.com" "myPassword" To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Get the quota for a quota root (an empty string queries the default quota root).
    Get ComGetQuota Of hoImap "" To sQuotaJson
    Get ComLastMethodSuccess Of hoImap To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln sQuotaJson

    //  JSON parsing code for this result can be generated at Chilkat's online tool:
    //  https://tools.chilkat.io/jsonParse

    Get ComDisconnect Of hoImap To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End



End_Procedure