Xbase++
Xbase++
Get an IMAP Mailbox Quota
See more IMAP Examples
Demonstrates the Chilkat Imap.GetQuota method, which sends the IMAP GETQUOTA command for a quota root and returns the server response as JSON. The server must advertise the IMAP QUOTA extension. This example queries the default quota root.
Tip: JSON parsing code for this result can be generated at Chilkat Tools.
Background: Mail servers often cap how much storage an account may use. The IMAP
QUOTA extension reports the current usage and limit for a quota root — a scope that may cover one mailbox or a whole account. Reading it lets an application warn a user who is nearing their limit, or refuse to append large messages that would exceed it. Check HasCapability for QUOTA first, since not all servers support it.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oImap
LOCAL cQuotaJson
nSuccess := 0
// Demonstrates the Imap.GetQuota method, which sends the IMAP GETQUOTA command for a quota
// root and returns the server response as JSON. The server must advertise the IMAP QUOTA
// extension.
oImap := CreateObject("Chilkat.Imap")
oImap:Ssl := 1
oImap:Port := 993
nSuccess := oImap:Connect("imap.example.com")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
nSuccess := oImap:Login("user@example.com", "myPassword")
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
// Get the quota for a quota root (an empty string queries the default quota root).
cQuotaJson := oImap:GetQuota("")
IF (oImap:LastMethodSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
? cQuotaJson
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
nSuccess := oImap:Disconnect()
IF (nSuccess == 0)
? oImap:LastErrorText
oImap:destroy()
RETURN
ENDIF
oImap:destroy()