jstedfast/MailKit · error · NotSupportedException
The SAVEDATESUPPORTED search term is not supported by the…
Error message
The SAVEDATESUPPORTED search term is not supported by the IMAP server.
What it means
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.
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.
Example fix
// before
var uids = folder.Search(SearchQuery.SaveDateSupported());
// after
if ((client.Capabilities & ImapCapabilities.SaveDate) != 0)
uids = folder.Search(SearchQuery.SaveDateSupported());
else
uids = Array.Empty<UniqueId>(); // savedate not available on this server Defensive patterns
Strategy: validation
Validate before calling
if ((client.Capabilities & ImapCapabilities.SaveDate) == 0)
return Array.Empty<UniqueId>(); // savedate terms unusable Type guard
bool SupportsSaveDate(ImapClient c) => (c.Capabilities & ImapCapabilities.SaveDate) != 0;
Try / catch
try {
return folder.Search(SearchQuery.SaveDateSupported());
} catch (NotSupportedException) {
return Array.Empty<UniqueId>();
} Prevention
- 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.
When it happens
Trigger: Calling folder.Search(SearchQuery.SaveDateSupported()) or composing it with other terms on a server without ImapCapabilities.SaveDate.
Common situations: 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.
Related errors
- The SAVEDBEFORE search term is not supported by the IMAP…
- The SAVEDON search term is not supported by the IMAP server.
- 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/96c0799107e36791.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapFolderSearch.cs:291
throw new NotSupportedException ("The OLDER search term is not supported by the IMAP server.");
numeric = (NumericSearchQuery) query;
builder.Append ("OLDER ");
builder.Append (numeric.Value.ToString (CultureInfo.InvariantCulture));
break;
case SearchTerm.Or:
builder.Append ("OR ");
binary = (BinarySearchQuery) query;
BuildQuery (builder, binary.Left, args, true, ref charset);
builder.Append (' ');
BuildQuery (builder, binary.Right, args, true, ref charset);
break;
case SearchTerm.Recent:
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));View on GitHub (pinned to 9d3859a785)