imap_find_thread_messages
Find messages in a search folder that share conversation threads with a source folder, catching replies that arrived after sorting via IMAP header search.
Instructions
Find messages in searchFolder that belong to the same conversation threads as messages already in sourceFolder. Useful for catching replies that arrived after a thread was sorted. Works on any IMAP server (uses RFC 3501 HEADER search on In-Reply-To and References). Set includeBody=true to also return the parsed body for each found thread message in one round-trip — avoids the N+1 cost of calling imap_get_email per thread member.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| accountId | No | Account ID (from imap_list_accounts). Optional if accountName is given or only one account is configured. | |
| bodyFormat | No | How to render the body when `includeBody` is true. Mirrors `imap_get_email` — "markdown" (default) returns clean Markdown; "text" returns plain text; "html" returns raw HTML; "auto" prefers substantive text/plain, else Markdown. | markdown |
| accountName | No | Account name instead of accountId. Optional if accountId is given or only one account is configured. | |
| includeBody | No | If true, also fetch the parsed message body for each found thread message in the same round-trip and return it alongside headers (avoids the N+1 cost of calling imap_get_email per thread member). Body is rendered per `bodyFormat` and capped at `bodyMaxLength` characters per field. | |
| searchFolder | No | Folder to search for related thread messages (default: INBOX) | INBOX |
| sourceFolder | Yes | Folder containing the already-sorted thread messages (e.g. "Review.Articles") | |
| bodyMaxLength | No | Per-message cap (in characters) for each rendered body field when `includeBody` is true. Defaults to 10000 to match `imap_get_email`. | |
| searchReferences | No | Also search the References header for multi-level threads (default: true) |