{"record":{"id":"3ae720856fef4dc3","repo":"jstedfast/MailKit","slug":"the-qresync-extension-has-not-been-enabled","errorCode":null,"errorMessage":"The QRESYNC extension has not been enabled.","messagePattern":"The QRESYNC extension has not been enabled\\.","errorType":"exception","errorClass":"InvalidOperationException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolder.cs","lineNumber":345,"sourceCode":"\n\t\t\treturn Task.CompletedTask;\n\t\t}\n\n\t\tImapCommand QueueOpenCommand (FolderAccess access, uint uidValidity, ulong highestModSeq, IList<UniqueId> uids, CancellationToken cancellationToken)\n\t\t{\n\t\t\tif (access != FolderAccess.ReadOnly && access != FolderAccess.ReadWrite)\n\t\t\t\tthrow new ArgumentOutOfRangeException (nameof (access));\n\n\t\t\tif (uids == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (uids));\n\n\t\t\tCheckState (false, false);\n\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.QuickResync) == 0)\n\t\t\t\tthrow new NotSupportedException (\"The IMAP server does not support the QRESYNC extension.\");\n\n\t\t\tif (!Supports (FolderFeature.QuickResync))\n\t\t\t\tthrow new InvalidOperationException (\"The QRESYNC extension has not been enabled.\");\n\n\t\t\tstring qresync;\n\n\t\t\tif ((Engine.Capabilities & ImapCapabilities.Annotate) != 0 && Engine.QuirksMode != ImapQuirksMode.iCloud)\n\t\t\t\tqresync = string.Format (CultureInfo.InvariantCulture, \"(ANNOTATE QRESYNC ({0} {1}\", uidValidity, highestModSeq);\n\t\t\telse\n\t\t\t\tqresync = string.Format (CultureInfo.InvariantCulture, \"(QRESYNC ({0} {1}\", uidValidity, highestModSeq);\n\n\t\t\tif (uids.Count > 0) {\n\t\t\t\tvar set = UniqueIdSet.ToString (uids);\n\t\t\t\tqresync += \" \" + set;\n\t\t\t}\n\n\t\t\tqresync += \"))\";\n\n\t\t\tvar command = string.Format (\"{0} %F {1}\\r\\n\", SelectOrExamine (access), qresync);\n\t\t\tvar ic = new ImapCommand (Engine, cancellationToken, this, command, this);\n\t\t\tic.RegisterUntaggedHandler (\"FETCH\", UntaggedQResyncFetchHandler);","sourceCodeStart":327,"sourceCodeEnd":363,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolder.cs#L327-L363","documentation":"This InvalidOperationException is thrown by QueueOpenCommand when the server supports QRESYNC (capability advertised) but QRESYNC was not enabled on the client connection. QRESYNC must be enabled during connection via ImapClient capabilities/EnableCommand before a folder can be opened with quick-resync data.","triggerScenarios":"Opening a folder with a highestModSeq/QRESYNC argument when Supports(FolderFeature.QuickResync) is false - i.e. ImapClient was created/connect without enabling QRESYNC (missing ImapCapabilities.QuickResync in client.Capabilities setup or EnableCommand not issued / EnableQResync option not set).","commonSituations":"Setting client.Capabilities to a subset that drops QuickResync before connect; forgetting ImapClient.EnableQResync = true (or equivalent EnableCommand(ImapCommand.QResync)) before connecting; using a client wrapper that strips extensions.","solutions":["Set client.EnableQResync = true (or include the QRESYNC enable flag/EnableCommand) BEFORE calling Connect so the extension is enabled during authentication.","If using custom Capabilities, ensure ImapCapabilities.QuickResync is included when constructing ImapClient.","Verify Supports(FolderFeature.QuickResync) on the client after connect; if false, fall back to plain Open.","Restart the connection after enabling - the enable flag is sent at login time and cannot be applied retroactively to a live session in older servers."],"exampleFix":"// before\nvar client = new ImapClient();\nclient.Connect(host, 993, true);\nclient.Authenticate(user, pass);\nfolder.Open(FolderAccess.ReadWrite, highestModSeq); // throws\n\n// after\nvar client = new ImapClient();\nclient.EnableQResync = true; // or client.Capabilities |= ImapCapabilities.QuickResync\nclient.Connect(host, 993, true);\nclient.Authenticate(user, pass);\nfolder.Open(FolderAccess.ReadWrite, highestModSeq);","handlingStrategy":"validation","validationCode":"var canQResync = (client.Capabilities & ImapCapabilities.QuickResync) != 0 && client.Supports(FolderFeature.QuickResync);\nif (!canQResync) folder.Open(FolderAccess.ReadWrite);","typeGuard":null,"tryCatchPattern":"try { folder.Open(access, highestModSeq); } catch (InvalidOperationException) { EnableQResyncAndReconnect(client); folder.Open(access, highestModSeq); }","preventionTips":["Set EnableQResync (or include QuickResync in Capabilities) BEFORE calling Connect - it cannot be toggled on a live session afterwards.","Create clients via a factory that always applies the QRESYNC setting.","Assert client.Supports(FolderFeature.QuickResync) after connect in debug builds.","Keep custom Capabilities subsets in sync with the extension flags you use."],"tags":["imap","mailkit","qresync","client-configuration"],"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"}