jstedfast/MailKit · error · NotSupportedException
The SAVEDSINCE search term is not supported by the IMAP…
Error message
The SAVEDSINCE search term is not supported by the IMAP server.
What it means
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.
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.
Example fix
// before
var uids = folder.Search(SearchQuery.SavedSince(lastSync));
// after
var uids = (client.Capabilities & ImapCapabilities.SaveDate) != 0
? folder.Search(SearchQuery.SavedSince(lastSync))
: folder.Search(SearchQuery.DeliveredSince(lastSync)); Defensive patterns
Strategy: fallback
Validate before calling
var q = (client.Capabilities & ImapCapabilities.SaveDate) != 0
? SearchQuery.SavedSince(date)
: SearchQuery.DeliveredSince(date); Type guard
bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;
Try / catch
try {
return folder.Search(SearchQuery.SavedSince(lastSync));
} catch (NotSupportedException) {
return folder.Search(SearchQuery.DeliveredSince(lastSync));
} Prevention
- 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.
When it happens
Trigger: Calling folder.Search(SearchQuery.SavedSince(someDate)) or combining it in an AND/OR expression on a server without ImapCapabilities.SaveDate.
Common situations: Incremental-sync code using savedate as a change cursor run against servers without SAVEDATE; Gmail/Exchange migrations are typical.
Related errors
- The SAVEDATESUPPORTED search term is not supported by the…
- The SAVEDBEFORE search term is not supported by the IMAP…
- The SAVEDON search term is not supported by the IMAP server.
- The ANNOTATION search term is not supported by the IMAP…
- The FILTER search term is not supported by the IMAP server.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/797060c0ea89b2f4.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapFolderSearch.cs:313
case SearchTerm.SavedBefore:
if ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)
throw new NotSupportedException ("The SAVEDBEFORE search term is not supported by the IMAP server.");
date = (DateSearchQuery) query;
builder.Append ("SAVEDBEFORE ");
builder.Append (FormatDateTime (date.Date));
break;
case SearchTerm.SavedOn:
if ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)
throw new NotSupportedException ("The SAVEDON search term is not supported by the IMAP server.");
date = (DateSearchQuery) query;
builder.Append ("SAVEDON ");
builder.Append (FormatDateTime (date.Date));
break;
case SearchTerm.SavedSince:
if ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)
throw new NotSupportedException ("The SAVEDSINCE search term is not supported by the IMAP server.");
date = (DateSearchQuery) query;
builder.Append ("SAVEDSINCE ");
builder.Append (FormatDateTime (date.Date));
break;
case SearchTerm.Seen:
builder.Append ("SEEN");
break;
case SearchTerm.SentBefore:
date = (DateSearchQuery) query;
builder.Append ("SENTBEFORE ");
builder.Append (FormatDateTime (date.Date));
break;
case SearchTerm.SentOn:
date = (DateSearchQuery) query;
builder.Append ("SENTON ");
builder.Append (FormatDateTime (date.Date));
break;View on GitHub (pinned to 9d3859a785)