{"record":{"id":"5b91ff1bcd585062","repo":"jstedfast/MailKit","slug":"the-folder-does-not-support-partial-searches","errorCode":null,"errorMessage":"The folder does not support partial searches.","messagePattern":"The folder does not support partial searches\\.","errorType":"exception","errorClass":"NotSupportedException","httpStatus":null,"severity":"error","filePath":"MailKit/MailFolder.cs","lineNumber":8644,"sourceCode":"\t\t/// </exception>\n\t\t/// <exception cref=\"System.IO.IOException\">\n\t\t/// An I/O error occurred.\n\t\t/// </exception>\n\t\t/// <exception cref=\"ProtocolException\">\n\t\t/// The server's response contained unexpected tokens.\n\t\t/// </exception>\n\t\t/// <exception cref=\"CommandException\">\n\t\t/// The command failed.\n\t\t/// </exception>\n\t\tpublic virtual SearchResults Search (SearchOptions options, SearchQuery query, PartialRange partialRange, CancellationToken cancellationToken = default)\n\t\t{\n\t\t\tif ((options & SearchOptions.All) != 0)\n\t\t\t\tthrow new ArgumentException (\"The SearchOptions.All flag cannot be combined with a partial range.\", nameof (options));\n\n\t\t\tif (query == null)\n\t\t\t\tthrow new ArgumentNullException (nameof (query));\n\n\t\t\tthrow new NotSupportedException (\"The folder does not support partial searches.\");\n\t\t}\n\n\t\t/// <summary>\n\t\t/// Asynchronously search the folder for messages matching the specified query, returning only the specified range of results.\n\t\t/// </summary>\n\t\t/// <remarks>\n\t\t/// <para>Asynchronously searches the folder for messages matching the specified query, returning only the\n\t\t/// search results within the specified range.</para>\n\t\t/// <para>Positive positions within the <paramref name=\"partialRange\"/> range are relative to the oldest matching\n\t\t/// message while negative positions are relative to the newest matching message. For example, a range of\n\t\t/// <c>1:500</c> will return the oldest 500 results while a range of <c>-1:-500</c> will return the newest\n\t\t/// 500 results.</para>\n\t\t/// <note type=\"note\">If the range specified by <paramref name=\"partialRange\"/> references results beyond the end\n\t\t/// of the complete set of matching messages, then the results will only contain the unique identifiers that\n\t\t/// fall within the range (if any).</note>\n\t\t/// </remarks>\n\t\t/// <returns>The search results.</returns>\n\t\t/// <param name=\"options\">The search options.</param>","sourceCodeStart":8626,"sourceCodeEnd":8662,"githubUrl":"https://github.com/jstedfast/MailKit/blob/9d3859a7855e3e17582c07fd01972b8e262bf176/MailKit/MailFolder.cs#L8626-L8662","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nvar results = folder.Search(SearchOptions.None, query, new PartialRange(0, 10));\n// after\nvar all = folder.Search(SearchOptions.None, query);\nvar page = all.Skip(0).Take(10).ToArray();","handlingStrategy":"try-catch","validationCode":"if (folder is not ImapFolder)\n    pageResultsLocally(folder, query);\nelse\n    results = folder.Search(SearchOptions.None, query, partialRange);","typeGuard":"bool supportsPartialSearch = folder is ImapFolder;","tryCatchPattern":"try {\n    results = folder.Search(SearchOptions.None, query, partialRange);\n} catch (NotSupportedException) {\n    var all = folder.Search(SearchOptions.None, query);\n    results = all.Skip(skip).Take(take).ToArray();\n}","preventionTips":["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"],"tags":["mailkit","not-supported","search","partial-range"],"backgroundTag":"unsupported-operation","analyzedSha":"9d3859a7855e3e17582c07fd01972b8e262bf176","analyzedAt":"2026-09-15T15:46:11.592Z","contentChangedAt":"2026-09-15T15:46:11.592Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}