Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Imap
integer li_QuotaKb

li_Success = 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.

loo_Imap = create oleobject
li_rc = loo_Imap.ConnectToNewObject("Chilkat.Imap")
if li_rc < 0 then
    destroy loo_Imap
    MessageBox("Error","Connecting to COM object failed")
    return
end if

loo_Imap.Ssl = 1
loo_Imap.Port = 993

li_Success = loo_Imap.Connect("imap.example.com")
if li_Success = 0 then
    Write-Debug loo_Imap.LastErrorText
    destroy loo_Imap
    return
end if

li_Success = loo_Imap.Login("user@example.com","myPassword")
if li_Success = 0 then
    Write-Debug loo_Imap.LastErrorText
    destroy loo_Imap
    return
end if

//  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.
li_QuotaKb = 500000
li_Success = loo_Imap.SetQuota("Mailbox","STORAGE",li_QuotaKb)
if li_Success = 0 then
    Write-Debug loo_Imap.LastErrorText
    destroy loo_Imap
    return
end if

Write-Debug "Quota set."

li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
    Write-Debug loo_Imap.LastErrorText
    destroy loo_Imap
    return
end if



destroy loo_Imap