{"record":{"id":"c84bf6cd099ce37a","repo":"jstedfast/MailKit","slug":"the-savedon-search-term-is-not-supported-by-the-imap-server","errorCode":null,"errorMessage":"The SAVEDON search term is not supported by the IMAP server.","messagePattern":"The SAVEDON search term is not supported by the IMAP server\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/Net/Imap/ImapFolderSearch.cs","lineNumber":305,"sourceCode":"\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));\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;","sourceCodeStart":287,"sourceCodeEnd":323,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/Net/Imap/ImapFolderSearch.cs#L287-L323","documentation":"BuildQuery throws this NotSupportedException when a SearchQuery.SavedOn(date) term is used but the server lacks the SAVEDATE capability (RFC 8514). SAVEDON matches messages whose savedate falls on the given date. MailKit validates ImapCapabilities.SaveDate while serializing the query and throws before issuing the command.","triggerScenarios":"Calling folder.Search(SearchQuery.SavedOn(someDate)) on a server whose capabilities exclude ImapCapabilities.SaveDate.","commonSituations":"Same family as SavedBefore/SavedSince: code written against SAVEDATE-capable servers (newer Dovecot/Cyrus) deployed to Gmail, Exchange, or older servers.","solutions":["Check (client.Capabilities & ImapCapabilities.SaveDate) != 0 before using SavedOn.","Use SearchQuery.DeliveredOn(date) (INTERNALDATE) as a universal fallback.","Move to a server implementing RFC 8514 if save-date accuracy is required."],"exampleFix":"// before\nvar uids = folder.Search(SearchQuery.SavedOn(DateTime.Today));\n\n// after\nvar day = DateTime.Today;\nvar uids = (client.Capabilities & ImapCapabilities.SaveDate) != 0\n    ? folder.Search(SearchQuery.SavedOn(day))\n    : folder.Search(SearchQuery.DeliveredOn(day));","handlingStrategy":"fallback","validationCode":"var q = (client.Capabilities & ImapCapabilities.SaveDate) != 0\n    ? SearchQuery.SavedOn(date)\n    : SearchQuery.DeliveredOn(date);","typeGuard":"bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;","tryCatchPattern":"try {\n    return folder.Search(SearchQuery.SavedOn(date));\n} catch (NotSupportedException) {\n    return folder.Search(SearchQuery.DeliveredOn(date));\n}","preventionTips":["Group all SAVEDATE search terms behind a single SupportsSaveDate guard.","Verify SAVEDATE support against each deployment target before shipping.","Keep a portable RFC 3501-only search builder for cross-provider code."],"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"}