{"record":{"id":"96c0799107e36791","repo":"jstedfast/MailKit","slug":"the-savedatesupported-search-term-is-not-supported-by-the","errorCode":null,"errorMessage":"The SAVEDATESUPPORTED search term is not supported by the IMAP server.","messagePattern":"The SAVEDATESUPPORTED search term is not supported by the IMAP server\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolderSearch.cs","lineNumber":291,"sourceCode":"\t\t\t\t\tthrow new NotSupportedException (\"The OLDER search term is not supported by the IMAP server.\");\n\n\t\t\t\tnumeric = (NumericSearchQuery) query;\n\t\t\t\tbuilder.Append (\"OLDER \");\n\t\t\t\tbuilder.Append (numeric.Value.ToString (CultureInfo.InvariantCulture));\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.Or:\n\t\t\t\tbuilder.Append (\"OR \");\n\t\t\t\tbinary = (BinarySearchQuery) query;\n\t\t\t\tBuildQuery (builder, binary.Left, args, true, ref charset);\n\t\t\t\tbuilder.Append (' ');\n\t\t\t\tBuildQuery (builder, binary.Right, args, true, ref charset);\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.Recent:\n\t\t\t\tbuilder.Append (\"RECENT\");\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SaveDateSupported:\n\t\t\t\tif ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)\n\t\t\t\t\tthrow new NotSupportedException (\"The SAVEDATESUPPORTED search term is not supported by the IMAP server.\");\n\n\t\t\t\tbuilder.Append (\"SAVEDATESUPPORTED\");\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SavedBefore:\n\t\t\t\tif ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)\n\t\t\t\t\tthrow new NotSupportedException (\"The SAVEDBEFORE search term is not supported by the IMAP server.\");\n\n\t\t\t\tdate = (DateSearchQuery) query;\n\t\t\t\tbuilder.Append (\"SAVEDBEFORE \");\n\t\t\t\tbuilder.Append (FormatDateTime (date.Date));\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SavedOn:\n\t\t\t\tif ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)\n\t\t\t\t\tthrow new NotSupportedException (\"The SAVEDON search term is not supported by the IMAP server.\");\n\n\t\t\t\tdate = (DateSearchQuery) query;\n\t\t\t\tbuilder.Append (\"SAVEDON \");\n\t\t\t\tbuilder.Append (FormatDateTime (date.Date));","sourceCodeStart":273,"sourceCodeEnd":309,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolderSearch.cs#L273-L309","documentation":"BuildQuery throws this NotSupportedException when a SearchQuery.SaveDateSupported term is used but the server lacks the SAVEDATE capability (RFC 8514). SAVEDATESUPPORTED matches messages whose savedate is supported; saving date is a server-stored timestamp of the last modification. MailKit checks ImapCapabilities.SaveDate during query serialization and fails fast.","triggerScenarios":"Calling folder.Search(SearchQuery.SaveDateSupported()) or composing it with other terms on a server without ImapCapabilities.SaveDate.","commonSituations":"Code relying on RFC 8514 SAVEDATE against servers that haven't implemented it (only some recent servers do, e.g. newer Dovecot); Gmail/Exchange lack it.","solutions":["Check (client.Capabilities & ImapCapabilities.SaveDate) != 0 before using any SaveDate-related search term.","Substitute internal-date-based queries (DeliveredBefore/DeliveredSince) which approximate the last-modification time.","Upgrade the IMAP server to a version implementing SAVEDATE if savedate semantics are required."],"exampleFix":"// before\nvar uids = folder.Search(SearchQuery.SaveDateSupported());\n\n// after\nif ((client.Capabilities & ImapCapabilities.SaveDate) != 0)\n    uids = folder.Search(SearchQuery.SaveDateSupported());\nelse\n    uids = Array.Empty<UniqueId>(); // savedate not available on this server","handlingStrategy":"validation","validationCode":"if ((client.Capabilities & ImapCapabilities.SaveDate) == 0)\n    return Array.Empty<UniqueId>(); // savedate terms unusable","typeGuard":"bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;","tryCatchPattern":"try {\n    return folder.Search(SearchQuery.SaveDateSupported());\n} catch (NotSupportedException) {\n    return Array.Empty<UniqueId>();\n}","preventionTips":["Treat the whole SaveDate family (Supported/Before/On/Since) as one gated feature.","Check capabilities once at connect and cache the result.","Design sync logic that does not depend on SAVEDATE for portability."],"tags":["imap","search","capability-check","savedate"],"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-15T23:17:13.987Z"}