Tcl
Tcl
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 Tcl Downloads
load ./chilkat.dll
set 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.
set imap [new_CkImap]
CkImap_put_Ssl $imap 1
CkImap_put_Port $imap 993
set success [CkImap_Connect $imap "imap.example.com"]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
set success [CkImap_Login $imap "user@example.com" "myPassword"]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
# GetQuotaRoot returns a JSON string, so assign it to a string variable and check success.
set jsonStr [CkImap_getQuotaRoot $imap "Inbox"]
if {[CkImap_get_LastMethodSuccess $imap] == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
puts "$jsonStr"
# JSON parsing code for this result can be generated at Chilkat's online tool:
# https://tools.chilkat.io/jsonParse
set success [CkImap_Disconnect $imap]
if {$success == 0} then {
puts [CkImap_lastErrorText $imap]
delete_CkImap $imap
exit
}
delete_CkImap $imap