Sample code for 30+ languages & platforms
PureBasic

Set an IMAP Mailbox Quota (SETQUOTA)

See more IMAP Examples

Demonstrates the Chilkat Imap.SetQuota method, which sends the IMAP SETQUOTA command. The first argument is the quota root, the second is the resource (STORAGE or MESSAGE), and the third is the limit. The server must support the IMAP QUOTA extension.

Background: Setting a quota is an administrative operation, so the logged-in account must have permission to change it. For the STORAGE resource the limit is measured in units of 1024 octets, so a value of 500000 is roughly 500,000,000 bytes; MESSAGE instead caps the number of messages. Use GetQuotaRoot to read the current usage and limits back.

Chilkat PureBasic Downloads

PureBasic
IncludeFile "CkImap.pb"

Procedure ChilkatExample()

    success.i = 0

    ;  Demonstrates the Imap.SetQuota method, which sends the IMAP SETQUOTA command.  The 1st
    ;  argument is the quota root, the 2nd is the resource ("STORAGE" or "MESSAGE"), and the 3rd is
    ;  the limit.  The server must support the IMAP QUOTA extension.

    imap.i = CkImap::ckCreate()
    If imap.i = 0
        Debug "Failed to create object."
        ProcedureReturn
    EndIf

    CkImap::setCkSsl(imap, 1)
    CkImap::setCkPort(imap, 993)

    success = CkImap::ckConnect(imap,"imap.example.com")
    If success = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    success = CkImap::ckLogin(imap,"user@example.com","myPassword")
    If success = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    ;  Set the STORAGE limit for the "Mailbox" quota root.  STORAGE is measured in units of 1024
    ;  octets, so 500000 is approximately 500,000,000 bytes.
    quotaKb.i = 500000
    success = CkImap::ckSetQuota(imap,"Mailbox","STORAGE",quotaKb)
    If success = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf

    Debug "Quota set."

    success = CkImap::ckDisconnect(imap)
    If success = 0
        Debug CkImap::ckLastErrorText(imap)
        CkImap::ckDispose(imap)
        ProcedureReturn
    EndIf



    CkImap::ckDispose(imap)


    ProcedureReturn
EndProcedure