jstedfast/MailKit · error · NotSupportedException

The ImapFolder does not support mod-sequences.

Error message

The ImapFolder does not support mod-sequences.

What it means

QueueStoreCommands throws NotSupportedException when a Store request specifies UnchangedSince (CONDSTORE conditional STORE) but the folder does not support mod-sequences. CONDTSTORE requires the server to advertise CONDSTORE (or QRESYNC) and the folder to have mod-sequence state; MailKit refuses the operation rather than silently ignoring UnchangedSince.

Solutions

  1. Check (imapClient.Capabilities & ImapCapabilities.Condstore) != 0 (or Qresync) before setting UnchangedSince; omit it when unsupported.
  2. Recreate the request without UnchangedSince: new StoreFlagsRequest(StoreAction.Set, MessageFlags.Seen).
  3. Enable CONDSTORE (e.g. issue a mod-sequence FETCH or folder.EnableQiResync) if the server supports it, then retry.
  4. If optimistic concurrency is required, use a CONDSTORE-capable server or implement retry-on-conflict at the application level.

Example fix

// before
var request = new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen) { UnchangedSince = modSeq };
await folder.StoreAsync(uids, request);
// after
if ((client.Capabilities & ImapCapabilities.Condstore) != 0) {
    var request = new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen) { UnchangedSince = modSeq };
    await folder.StoreAsync(uids, request);
} else {
    await folder.StoreAsync(uids, new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen));
}
Defensive patterns

Strategy: fallback

Validate before calling

bool canCondstore = (client.Capabilities & ImapCapabilities.Condstore) != 0
                 || (client.Capabilities & ImapCapabilities.Qresync) != 0;
var request = canCondstore
    ? new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen) { UnchangedSince = modSeq }
    : new StoreFlagsRequest(StoreAction.Add, MessageFlags.Seen);
await folder.StoreAsync(uids, request);

Try / catch

try {
    await folder.StoreAsync(uids, requestWithUnchangedSince);
} catch (NotSupportedException) {
    await folder.StoreAsync(uids, requestWithoutUnchangedSince);
}

Prevention

When it happens

Trigger: Calling ImapFolder.Store(uids, request, ...) or StoreAsync with a StoreFlagsRequest/StoreLabelsRequest whose UnchangedSince is set, on a folder/server without CONDSTORE support (ImapClient.Capabilities lacks Condstore/Qresync), or before the folder established mod-sequence state.

Common situations: Code written against CONDSTORE-capable servers (Cyrus, Dovecot, Gmail) run against servers without it; setting UnchangedSince unconditionally without checking capabilities; capability checks performed on a different client/connection instance.

Understand the failure class

Background: UnsupportedOperationException and "is not supported" errors: when a library deliberately refuses a call — this error's family across 30 libraries.

Related errors


AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15). Data as JSON: /api/errors/ebb5b032678a2455. Report an issue: GitHub.

Appendix: source

Thrown at MailKit/Net/Imap/ImapFolderFlags.cs:88

						unmodified[i] = (int) (rc.UidSet[i].Id - 1);

					return unmodified;
				}
			}

			return Array.Empty<int> ();
		}

		IEnumerable<ImapCommand> QueueStoreCommands (IList<UniqueId> uids, IStoreFlagsRequest request, CancellationToken cancellationToken)
		{
			if (uids == null)
				throw new ArgumentNullException (nameof (uids));

			if (request == null)
				throw new ArgumentNullException (nameof (request));

			if (request.UnchangedSince.HasValue && !supportsModSeq)
				throw new NotSupportedException ("The ImapFolder does not support mod-sequences.");

			CheckState (true, true);

			if (uids.Count == 0)
				return Array.Empty<ImapCommand> ();

			int numKeywords = request.Keywords != null ? request.Keywords.Count : 0;
			string action;

			switch (request.Action) {
			case StoreAction.Add:
				if ((request.Flags & SettableFlags) == 0 && numKeywords == 0)
					return Array.Empty<ImapCommand> ();

				action = request.Silent ? "+FLAGS.SILENT" : "+FLAGS";
				break;
			case StoreAction.Remove:
				if ((request.Flags & SettableFlags) == 0 && numKeywords == 0)

View on GitHub (pinned to 9d3859a785)