Unicode C++
Unicode C++
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 Unicode C++ Downloads
#include <CkImapW.h>
void ChilkatSample(void)
{
bool success = false;
// 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.
CkImapW imap;
imap.put_Ssl(true);
imap.put_Port(993);
success = imap.Connect(L"imap.example.com");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
success = imap.Login(L"user@example.com",L"myPassword");
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
// Get the quota for a quota root (an empty string queries the default quota root).
const wchar_t *quotaJson = imap.getQuota(L"");
if (imap.get_LastMethodSuccess() == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
wprintf(L"%s\n",quotaJson);
// JSON parsing code for this result can be generated at Chilkat's online tool:
// https://tools.chilkat.io/jsonParse
success = imap.Disconnect();
if (success == false) {
wprintf(L"%s\n",imap.lastErrorText());
return;
}
}