{"record":{"id":"797060c0ea89b2f4","repo":"jstedfast/MailKit","slug":"the-savedsince-search-term-is-not-supported-by-the-imap","errorCode":null,"errorMessage":"The SAVEDSINCE search term is not supported by the IMAP server.","messagePattern":"The SAVEDSINCE search term is not supported by the IMAP server\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolderSearch.cs","lineNumber":313,"sourceCode":"\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));\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SavedSince:\n\t\t\t\tif ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)\n\t\t\t\t\tthrow new NotSupportedException (\"The SAVEDSINCE search term is not supported by the IMAP server.\");\n\n\t\t\t\tdate = (DateSearchQuery) query;\n\t\t\t\tbuilder.Append (\"SAVEDSINCE \");\n\t\t\t\tbuilder.Append (FormatDateTime (date.Date));\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.Seen:\n\t\t\t\tbuilder.Append (\"SEEN\");\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SentBefore:\n\t\t\t\tdate = (DateSearchQuery) query;\n\t\t\t\tbuilder.Append (\"SENTBEFORE \");\n\t\t\t\tbuilder.Append (FormatDateTime (date.Date));\n\t\t\t\tbreak;\n\t\t\tcase SearchTerm.SentOn:\n\t\t\t\tdate = (DateSearchQuery) query;\n\t\t\t\tbuilder.Append (\"SENTON \");\n\t\t\t\tbuilder.Append (FormatDateTime (date.Date));\n\t\t\t\tbreak;","sourceCodeStart":295,"sourceCodeEnd":331,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolderSearch.cs#L295-L331","documentation":"BuildQuery throws this NotSupportedException when a SearchQuery.SavedSince(date) term is used but the server does not advertise the SAVEDATE capability (RFC 8514). SAVEDSINCE matches messages whose savedate is on or after the given date. The capability gate fires during client-side query compilation in BuildQuery.","triggerScenarios":"Calling folder.Search(SearchQuery.SavedSince(someDate)) or combining it in an AND/OR expression on a server without ImapCapabilities.SaveDate.","commonSituations":"Incremental-sync code using savedate as a change cursor run against servers without SAVEDATE; Gmail/Exchange migrations are typical.","solutions":["Check (client.Capabilities & ImapCapabilities.SaveDate) != 0 before using SavedSince.","Fall back to SearchQuery.DeliveredSince(date) or use UIDVALIDITY/condestore-style sync mechanisms instead.","Upgrade to an SAVEDATE-capable server if savedate-driven incremental sync is a requirement."],"exampleFix":"// before\nvar uids = folder.Search(SearchQuery.SavedSince(lastSync));\n\n// after\nvar uids = (client.Capabilities & ImapCapabilities.SaveDate) != 0\n    ? folder.Search(SearchQuery.SavedSince(lastSync))\n    : folder.Search(SearchQuery.DeliveredSince(lastSync));","handlingStrategy":"fallback","validationCode":"var q = (client.Capabilities & ImapCapabilities.SaveDate) != 0\n    ? SearchQuery.SavedSince(date)\n    : SearchQuery.DeliveredSince(date);","typeGuard":"bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;","tryCatchPattern":"try {\n    return folder.Search(SearchQuery.SavedSince(lastSync));\n} catch (NotSupportedException) {\n    return folder.Search(SearchQuery.DeliveredSince(lastSync));\n}","preventionTips":["For incremental sync prefer UID-based tracking over any date-based term.","Check ImapCapabilities.SaveDate before any Saved* search term.","Unit-test search building against a capability set that mimics your production server."],"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-16T04:17:20.429Z"}