{"record":{"id":"365fcda7e704fb35","repo":"jstedfast/MailKit","slug":"the-imap-server-does-not-support-the-quota-extension","errorCode":null,"errorMessage":"The IMAP server does not support the QUOTA extension.","messagePattern":"The IMAP server does not support the QUOTA extension\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":3816,"sourceCode":"\t\t/// <param name=\"ic\">The IMAP command.</param>\n\t\t/// <param name=\"index\">The index.</param>\n\t\t/// <param name=\"doAsync\">Whether or not asynchronous IO methods should be used.</param>\n\t\tstatic Task UntaggedQuotaHandler (ImapEngine engine, ImapCommand ic, int index, bool doAsync)\n\t\t{\n\t\t\tif (doAsync)\n\t\t\t\treturn ParseQuotaAsync (engine, ic);\n\n\t\t\tParseQuota (engine, ic);\n\n\t\t\treturn Task.CompletedTask;\n\t\t}\n\n\t\tImapCommand QueueGetQuotaCommand (CancellationToken cancellationToken)\n\t\t{\n\t\t\tCheckState (false, false);\n\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.Quota) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the QUOTA extension.\");\n\n\t\t\tvar ic = new ImapCommand (Engine, cancellationToken, null, \"GETQUOTAROOT %F\\r\\n\", this);\n\t\t\tvar ctx = new QuotaContext ();\n\n\t\t\tic.RegisterUntaggedHandler (\"QUOTAROOT\", UntaggedQuotaRootHandler);\n\t\t\tic.RegisterUntaggedHandler (\"QUOTA\", UntaggedQuotaHandler);\n\t\t\tic.UserData = ctx;\n\n\t\t\tEngine.QueueCommand (ic);\n\n\t\t\treturn ic;\n\t\t}\n\n\t\tbool TryProcessGetQuotaResponse (ImapCommand ic, [NotNullWhen (true)] out string? encodedName, [NotNullWhen (true)] out Quota? quota)\n\t\t{\n\t\t\tvar ctx = (QuotaContext) ic.UserData!;\n\n\t\t\tProcessResponseCodes (ic, null);","sourceCodeStart":3798,"sourceCodeEnd":3834,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L3798-L3834","documentation":"GetQuota (and related quota APIs) depends on the IMAP QUOTA extension (RFC 2087/9208). MailKit checks ImapCapabilities.Quota before queueing GETQUOTAROOT and throws NotSupportedException when the server did not advertise it, as it cannot report storage usage/limits.","triggerScenarios":"Calling ImapFolder.GetQuota or ImapFolder.GetQuotaRoot on a server whose CAPABILITY response lacks QUOTA.","commonSituations":"Showing mailbox storage usage in an app connected to Gmail (which does not advertise IMAP QUOTA) or other consumer providers; expecting quota info on servers that expose it only via web APIs.","solutions":["Check (client.Capabilities & ImapCapabilities.Quota) != 0 before calling quota APIs","Obtain storage info from the provider's native API instead (e.g. Gmail API about/getStorageQuota)","Switch to an IMAP server that supports the QUOTA extension if IMAP-based quota is required","Catch NotSupportedException and hide/disable quota UI when unsupported"],"exampleFix":"// before\nvar quota = folder.GetQuota();\n// after\nif ((client.Capabilities & ImapCapabilities.Quota) != 0)\n    var quota = folder.GetQuota();\nelse\n    var quota = null; // server does not report quota over IMAP","handlingStrategy":"validation","validationCode":"if ((client.Capabilities & ImapCapabilities.Quota) == 0)\n    throw new NotSupportedException(\"Server does not support IMAP QUOTA\");","typeGuard":"bool SupportsQuota(ImapClient c) => (c.Capabilities & ImapCapabilities.Quota) != 0;","tryCatchPattern":"try {\n    var quota = folder.GetQuota();\n} catch (NotSupportedException ex) {\n    logger.LogInformation(ex, \"QUOTA unsupported; storage usage unavailable via IMAP\");\n    var quota = null;\n}","preventionTips":["Check ImapCapabilities.Quota before any GetQuota/GetQuotaRoot call","Use provider-native APIs (e.g. Gmail API) for storage info on servers without IMAP QUOTA","Treat quota as optional data in your UI (progressive enhancement)","Verify capability responses when onboarding a new IMAP host"],"tags":["imap","quota","not-supported","mailkit"],"backgroundTag":"feature-not-enabled","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}