PowerBuilder
PowerBuilder
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 PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Imap
string ls_JsonStr
li_Success = 0
// 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.
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
// GetQuotaRoot returns a JSON string, so assign it to a string variable and check success.
ls_JsonStr = loo_Imap.GetQuotaRoot("Inbox")
if loo_Imap.LastMethodSuccess = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
Write-Debug ls_JsonStr
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
li_Success = loo_Imap.Disconnect()
if li_Success = 0 then
Write-Debug loo_Imap.LastErrorText
destroy loo_Imap
return
end if
destroy loo_Imap