Sample code for 30+ languages & platforms
DataFlex

Get an IMAP Mailbox Quota (GETQUOTAROOT)

See more IMAP Examples

Demonstrates the Chilkat Imap.GetQuotaRoot method, which sends the IMAP GETQUOTAROOT command for a mailbox and returns the server response as JSON. The only argument is the mailbox name. The server must advertise the IMAP QUOTA capability. This example queries the quota that applies to the Inbox.

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

Background: This is how a client shows a storage bar such as "9 of 256000 used." A mailbox maps to a quota root, and a single root may govern several mailboxes that share the same allowance. The JSON response can include both the mailbox-to-root mapping (QUOTAROOT) and the resource usage and limit (QUOTA).

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

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

    Move False To iSuccess

    //  Demonstrates the Imap.GetQuotaRoot method, which sends the IMAP GETQUOTAROOT command for a
    //  mailbox and returns the server response as JSON.  The only argument is the mailbox name.

    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

    //  GetQuotaRoot returns a JSON string, so assign it to a string variable and check success.
    Get ComGetQuotaRoot Of hoImap "Inbox" To sJsonStr
    Get ComLastMethodSuccess Of hoImap To bTemp1
    If (bTemp1 = False) Begin
        Get ComLastErrorText Of hoImap To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln sJsonStr
    //  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