jstedfast/MailKit · error · NotSupportedException
The IMAP server does not support the SPECIAL-USE nor XLIST…
Error message
The IMAP server does not support the SPECIAL-USE nor XLIST extensions.
What it means
GetFolder(SpecialFolder) throws NotSupportedException when neither the SPECIAL-USE nor the legacy XLIST capability is present, since mapping well-known folders requires the server to advertise special-use attributes.
Solutions
- Check (client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0 before calling
- Fall back to GetFolder(client.PersonalNamespaces[0]) and match folders by name (INBOX, Drafts, Sent...)
- Enumerate client.GetFolders and inspect folder.Attributes for SpecialUse/Sent/Drafts flags where available
Example fix
// before
var drafts = client.GetFolder(SpecialFolder.Drafts);
// after
ImapFolder drafts;
if ((client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0)
drafts = client.GetFolder(SpecialFolder.Drafts);
else
drafts = (ImapFolder)client.GetFolder("Drafts"); Defensive patterns
Strategy: fallback
Validate before calling
bool canMap = (client.Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) != 0;
Try / catch
try { folder = client.GetFolder(SpecialFolder.Drafts); }
catch (NotSupportedException) { folder = client.GetFolder("Drafts") as ImapFolder; } Prevention
- Enumerate GetFolders + folder.Attributes to locate special folders manually
- Maintain a name-based fallback map (INBOX, Drafts, Sent, Trash)
- Log capabilities to catch servers lacking SPECIAL-USE early
When it happens
Trigger: Calling client.GetFolder(SpecialFolder.All/Drafts/etc.) against a server without SPECIAL-USE or XLIST; older servers pre-RFC 6154.
Common situations: Legacy mail servers or minimal proxies; code using SpecialFolder convenience API against servers that only list plain folders.
Related errors
- The IMAP server does not support the QRESYNC extension.
- The IMAP server does not support the UTF8=ACCEPT extension.
- The IMAP server does not support the ID extension.
- The IMAP server does not support the IDLE extension.
- The IMAP server does not support the NOTIFY extension.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/5836e9456119ed72.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/Net/Imap/ImapClient.cs:2292
/// The <see cref="ImapClient"/> has been disposed.
/// </exception>
/// <exception cref="ServiceNotConnectedException">
/// The <see cref="ImapClient"/> is not connected.
/// </exception>
/// <exception cref="ServiceNotAuthenticatedException">
/// The <see cref="ImapClient"/> is not authenticated.
/// </exception>
/// <exception cref="System.NotSupportedException">
/// The IMAP server does not support the SPECIAL-USE nor XLIST extensions.
/// </exception>
public override IMailFolder? GetFolder (SpecialFolder folder)
{
CheckDisposed ();
CheckConnected ();
CheckAuthenticated ();
if ((Capabilities & (ImapCapabilities.SpecialUse | ImapCapabilities.XList)) == 0)
throw new NotSupportedException ("The IMAP server does not support the SPECIAL-USE nor XLIST extensions.");
switch (folder) {
case SpecialFolder.All: return engine.All;
case SpecialFolder.Archive: return engine.Archive;
case SpecialFolder.Drafts: return engine.Drafts;
case SpecialFolder.Flagged: return engine.Flagged;
case SpecialFolder.Important: return engine.Important;
case SpecialFolder.Junk: return engine.Junk;
case SpecialFolder.Sent: return engine.Sent;
case SpecialFolder.Trash: return engine.Trash;
default: throw new ArgumentOutOfRangeException (nameof (folder));
}
}
/// <summary>
/// Get the folder for the specified namespace.
/// </summary>
/// <remarks>View on GitHub (pinned to 9d3859a785)