jstedfast/MailKit · error · NotSupportedException
The SAVEDON search term is not supported by the IMAP server.
Error message
The SAVEDON search term is not supported by the IMAP server.
What it means
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.
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.
Example fix
// before
var uids = folder.Search(SearchQuery.SavedOn(DateTime.Today));
// after
var day = DateTime.Today;
var uids = (client.Capabilities & ImapCapabilities.SaveDate) != 0
? folder.Search(SearchQuery.SavedOn(day))
: folder.Search(SearchQuery.DeliveredOn(day)); Defensive patterns
Strategy: fallback
Validate before calling
var q = (client.Capabilities & ImapCapabilities.SaveDate) != 0
? SearchQuery.SavedOn(date)
: SearchQuery.DeliveredOn(date); Type guard
bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;
Try / catch
try {
return folder.Search(SearchQuery.SavedOn(date));
} catch (NotSupportedException) {
return folder.Search(SearchQuery.DeliveredOn(date));
} Prevention
- 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.
When it happens
Trigger: Calling folder.Search(SearchQuery.SavedOn(someDate)) on a server whose capabilities exclude ImapCapabilities.SaveDate.
Common situations: Same family as SavedBefore/SavedSince: code written against SAVEDATE-capable servers (newer Dovecot/Cyrus) deployed to Gmail, Exchange, or older servers.
Related errors
- The SAVEDATESUPPORTED search term is not supported by the…
- The SAVEDBEFORE search term is not supported by the IMAP…
- The SAVEDSINCE search term is not supported by the IMAP…
- 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/c84bf6cd099ce37a.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapFolderSearch.cs:305
builder.Append ("RECENT");
break;
case SearchTerm.SaveDateSupported:
if ((Engine.Capabilities & ImapCapabilities.SaveDate) == 0)
throw new NotSupportedException ("The SAVEDATESUPPORTED search term is not supported by the IMAP server.");
builder.Append ("SAVEDATESUPPORTED");
break;
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;View on GitHub (pinned to 9d3859a785)