jstedfast/MailKit · error · NotSupportedException
The folder does not support partial searches.
Error message
The folder does not support partial searches.
What it means
MailFolder's base-class Search overload that takes a PartialRange is a virtual placeholder that is only implemented by servers/folders supporting partial range search (e.g. IMAP with the ESEARCH extension). The base MailFolder implementation throws NotSupportedException to signal that this folder type does not support searching a subset/range of results. Callers must use the non-partial Search overloads or connect via an IMAP folder that supports partial search.
Solutions
- Use the non-partial Search(SearchQuery) / Search(SearchOptions, SearchQuery) overloads and take/skip results client-side instead of a PartialRange.
- Ensure the folder is an ImapFolder connected to a server supporting partial search results (check folder/support capabilities) before calling the PartialRange overload.
- If partial results are needed for pagination, fetch a range of UIDs/messummary objects instead of relying on partial search.
Example fix
// before var results = folder.Search(SearchOptions.None, query, new PartialRange(0, 10)); // after var all = folder.Search(SearchOptions.None, query); var page = all.Skip(0).Take(10).ToArray();
Defensive patterns
Strategy: try-catch
Validate before calling
if (folder is not ImapFolder)
pageResultsLocally(folder, query);
else
results = folder.Search(SearchOptions.None, query, partialRange); Type guard
bool supportsPartialSearch = folder is ImapFolder;
Try / catch
try {
results = folder.Search(SearchOptions.None, query, partialRange);
} catch (NotSupportedException) {
var all = folder.Search(SearchOptions.None, query);
results = all.Skip(skip).Take(take).ToArray();
} Prevention
- Only use PartialRange overloads on ImapFolder instances
- Prefer client-side Skip/Take on full Search results when server support is uncertain
- Catch NotSupportedException around capability-dependent folder APIs
When it happens
Trigger: Calling MailFolder.Search(SearchOptions, SearchQuery, PartialRange, CancellationToken) (or its overloads) on a MailFolder instance that has not overridden the virtual partial-search method — e.g. after the argument checks pass (query non-null, no SearchOptions.All flag) the virtual body throws.
Common situations: Using a non-IMAP folder (such as a local maildir/memory folder or a POP3-derived folder), or calling partial-range search before the folder is an ImapFolder that advertised the required capability.
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
- The folder does not support partial sorts.
- The IMAP server does not support the PARTIAL extension.
- The IMAP server does not support negative partial ranges.
- The SearchOptions.All flag cannot be combined with a…
- The IMAP server does not support the METADATA extension.
AI-assisted analysis of jstedfast/MailKit@9d3859a785 (2026-09-15).
Data as JSON: /api/errors/5b91ff1bcd585062.
Report an issue: GitHub.
Appendix: source
Thrown at MailKit/MailFolder.cs:8644
/// </exception>
/// <exception cref="System.IO.IOException">
/// An I/O error occurred.
/// </exception>
/// <exception cref="ProtocolException">
/// The server's response contained unexpected tokens.
/// </exception>
/// <exception cref="CommandException">
/// The command failed.
/// </exception>
public virtual SearchResults Search (SearchOptions options, SearchQuery query, PartialRange partialRange, CancellationToken cancellationToken = default)
{
if ((options & SearchOptions.All) != 0)
throw new ArgumentException ("The SearchOptions.All flag cannot be combined with a partial range.", nameof (options));
if (query == null)
throw new ArgumentNullException (nameof (query));
throw new NotSupportedException ("The folder does not support partial searches.");
}
/// <summary>
/// Asynchronously search the folder for messages matching the specified query, returning only the specified range of results.
/// </summary>
/// <remarks>
/// <para>Asynchronously searches the folder for messages matching the specified query, returning only the
/// search results within the specified range.</para>
/// <para>Positive positions within the <paramref name="partialRange"/> range are relative to the oldest matching
/// message while negative positions are relative to the newest matching message. For example, a range of
/// <c>1:500</c> will return the oldest 500 results while a range of <c>-1:-500</c> will return the newest
/// 500 results.</para>
/// <note type="note">If the range specified by <paramref name="partialRange"/> references results beyond the end
/// of the complete set of matching messages, then the results will only contain the unique identifiers that
/// fall within the range (if any).</note>
/// </remarks>
/// <returns>The search results.</returns>
/// <param name="options">The search options.</param>View on GitHub (pinned to 9d3859a785)