Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loImap
LOCAL lcJsonStr

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

loImap = CreateObject('Chilkat.Imap')

loImap.Ssl = 1
loImap.Port = 993

lnSuccess = loImap.Connect("imap.example.com")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

lnSuccess = loImap.Login("user@example.com","myPassword")
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

*  GetQuotaRoot returns a JSON string, so assign it to a string variable and check success.
lcJsonStr = loImap.GetQuotaRoot("Inbox")
IF (loImap.LastMethodSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

? lcJsonStr
*  JSON parsing code for this result can be generated at Chilkat's online tool:
*  https://tools.chilkat.io/jsonParse

lnSuccess = loImap.Disconnect()
IF (lnSuccess = 0) THEN
    ? loImap.LastErrorText
    RELEASE loImap
    CANCEL
ENDIF

RELEASE loImap