{"record":{"id":"4b5c26f9f9904da8","repo":"jstedfast/MailKit","slug":"the-imapfolder-does-not-support-annotations","errorCode":null,"errorMessage":"The ImapFolder does not support annotations.","messagePattern":"The ImapFolder does not support annotations\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolderAnnotations.cs","lineNumber":53,"sourceCode":"namespace MailKit.Net.Imap\n{\n\tpublic partial class ImapFolder\n\t{\n\t\tIEnumerable<ImapCommand> QueueStoreCommands (IList<UniqueId> uids, ulong? modseq, IList<Annotation> annotations, CancellationToken cancellationToken)\n\t\t{\n\t\t\tif (uids == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (uids));\n\n\t\t\tif (modseq.HasValue && !supportsModSeq)\n\t\t\t\tthrow new NotSupportedException (\"The ImapFolder does not support mod-sequences.\");\n\n\t\t\tif (annotations == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (annotations));\n\n\t\t\tCheckState (true, true);\n\n\t\t\tif (AnnotationAccess == AnnotationAccess.None)\n\t\t\t\tthrow new NotSupportedException (\"The ImapFolder does not support annotations.\");\n\n\t\t\tif (uids.Count == 0 || annotations.Count == 0)\n\t\t\t\treturn Array.Empty<ImapCommand> ();\n\n\t\t\tvar builder = new StringBuilder (\"UID STORE %s \");\n\t\t\tvar values = new List<object> ();\n\n\t\t\tif (modseq.HasValue) {\n\t\t\t\tbuilder.Append (\"(UNCHANGEDSINCE \");\n\t\t\t\tbuilder.Append (modseq.Value.ToString (CultureInfo.InvariantCulture));\n\t\t\t\tbuilder.Append (\") \");\n\t\t\t}\n\n\t\t\tImapUtils.FormatAnnotations (builder, annotations, values, true);\n\t\t\tbuilder.Append (\"\\r\\n\");\n\n\t\t\tvar command = builder.ToString ();\n\t\t\tvar args = values.ToArray ();","sourceCodeStart":35,"sourceCodeEnd":71,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolderAnnotations.cs#L35-L71","documentation":"ImapFolder.Store(uids, annotations) throws this NotSupportedException when the IMAP server did not advertise the ANNOTATE (or similar annotation) capability, so the folder's AnnotationAccess is AnnotationAccess.None. MailKit refuses to send a UID STORE command with annotation entries because the server would reject it. It is a capability check performed in QueueStoreCommands before any network command is queued.","triggerScenarios":"Calling Store(IList<UniqueId> uids, IList<Annotation> annotations) or its StoreAsync overload on an ImapFolder whose server lacks annotation support (AnnotationAccess == AnnotationAccess.None). Typical with servers like Gmail or older Dovecot builds that do not implement RFC 5257 ANNOTATE extension.","commonSituations":"Porting code that worked against a Cyrus/Dovecot server with annotations enabled to Gmail or Exchange; connecting to a server without the ANNOTATE capability listed in CAPABILITY response; assuming all IMAP servers support message annotations because the MailKit API exposes them.","solutions":["Check folder.AnnotationAccess != AnnotationAccess.None (and the client capabilities) before calling Store with annotations","If the server should support annotations, verify the IMAP server has the ANNOTATE extension enabled (e.g. Dovecot imap_annotation plugin, Cyrus 'annotations' option) and reconnect/re-open the folder","Skip or degrade annotation storage on servers without support, persisting metadata client-side instead"],"exampleFix":"// before\nfolder.Store(uids, annotations);\n// after\nif (folder.AnnotationAccess != AnnotationAccess.None)\n    folder.Store(uids, annotations);\nelse\n    // fall back: store annotations out-of-band or skip","handlingStrategy":"validation","validationCode":"if (folder.AnnotationAccess == AnnotationAccess.None)\n    throw new SkipOperationException(\"Server does not support IMAP annotations.\");\n// safe now:\nfolder.Store(uids, annotations);","typeGuard":null,"tryCatchPattern":"try {\n    folder.Store(uids, annotations);\n} catch (NotSupportedException) {\n    // degrade: persist annotations client-side or skip\n}","preventionTips":["Inspect folder.AnnotationAccess after opening the folder before any annotation API use","Log client.Capabilities at connect time to know which IMAP extensions the server supports","Feature-flag annotation code paths per server deployment"],"tags":["imap","mailkit","not-supported","annotations","capability-check"],"backgroundTag":"unsupported-operation","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}