jstedfast/MailKit · error · NotSupportedException
The ImapFolder does not support mod-sequences.
Error message
The ImapFolder does not support mod-sequences.
What it means
CheckCanFetch(IList<UniqueId>, IFetchRequest) — used by Fetch/FetchAsync by UID — throws this NotSupportedException when the fetch request sets ChangedSince but the folder's supportsModSeq flag is false. Fetching only messages changed since a mod-sequence requires the CONDSTORE extension (RFC 7162); MailKit validates this client-side instead of letting the server return BAD.
Solutions
- Check folder.SupportsModSeq before setting request.ChangedSince; if false, fall back to a full Fetch and diff client-side
- Verify the ImapClient advertises CONDSTORE/QRESYNC (client.Capabilities) and that the server has the extension enabled
- Clear the ChangedSince value on the IFetchRequest when unsupported
Example fix
// before
var request = new FetchRequest { Items = MessageSummaryItems.All, ChangedSince = lastModSeq };
var summaries = folder.Fetch(uids, request);
// after
if (folder.SupportsModSeq) {
request.ChangedSince = lastModSeq;
} else {
request.ChangedSince = null; // full fetch + client-side diff
}
var summaries = folder.Fetch(uids, request); Defensive patterns
Strategy: validation
Validate before calling
if (request.ChangedSince.HasValue && !folder.SupportsModSeq)
request.ChangedSince = null; // full fetch + client-side diff
var summaries = folder.Fetch(uids, request); Try / catch
try {
summaries = folder.Fetch(uids, request);
} catch (NotSupportedException) {
request.ChangedSince = null;
summaries = folder.Fetch(uids, request); // fallback full fetch
} Prevention
- Always gate ChangedSince on folder.SupportsModSeq
- Cache per-connection capability detection results and re-check after reconnect
- Design sync logic to work (slower) without CONDSTORE
When it happens
Trigger: Calling Fetch(IList<UniqueId> uids, IFetchRequest request) or FetchAsync where request.ChangedSince.HasValue and the IMAP server does not support CONDSTORE/QRESYNC (supportsModSeq == false).
Common situations: Implementing incremental sync (pull only changed messages since last known modseq) against Gmail, which lacks CONDSTORE; setting ChangedSince copied from sample sync code without checking capabilities; reconnecting to a different/misconfigured server that lost CONDSTORE.
Related errors
- The IMAP server does not support the PARTIAL extension.
- The set of unique identifiers is too large to fetch with a…
- The PARTIAL extension only supports UID-based FETCH…
- The ImapFolder does not support mod-sequences.
- The IMAP server does not support the METADATA extension.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/ab17f6ea8690c924.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapFolderFetch.cs:1096
MessageExpunged -= sctx.OnMessageExpunged;
}
}
internal static bool IsEmptyFetchRequest (IFetchRequest request)
{
return request.Items == MessageSummaryItems.None && (request.Headers == null || (request.Headers.Count == 0 && !request.Headers.Exclude));
}
bool CheckCanFetch (IList<UniqueId> uids, IFetchRequest request)
{
if (uids == null)
throw new ArgumentNullException (nameof (uids));
if (request == null)
throw new ArgumentNullException (nameof (request));
if (request.ChangedSince.HasValue && !supportsModSeq)
throw new NotSupportedException ("The ImapFolder does not support mod-sequences.");
if (request.PartialRange.HasValue && (Engine.Capabilities & ImapCapabilities.Partial) == 0)
throw new NotSupportedException ("The IMAP server does not support the PARTIAL extension.");
CheckState (true, false);
return uids.Count > 0 && !IsEmptyFetchRequest (request);
}
string CreateFetchCommand (IList<UniqueId> uids, IFetchRequest request, out bool previewText)
{
var query = FormatSummaryItems (Engine, request, out previewText);
var command = new StringBuilder ("UID FETCH %s ");
command.Append (query);
if (request.ChangedSince.HasValue || request.PartialRange.HasValue) {
command.Append (" (");View on GitHub (pinned to 9d3859a785)