search_messages
Search one email folder with filters such as sender, subject, date, read status, or attachments, returning message envelopes newest first without marking mail as read.
Instructions
Search one folder with structured filters and return message envelopes, newest first.
All filters are combined with AND. String filters use IMAP case-insensitive substring matching; multi-word values are quoted for you. Each result has uid, folder, message_id, subject, from/to/cc, date, flags, size, seen and flagged; pass folder + uid to read_email for the body. The folder is opened read-only, so searching never marks mail read.
Args: account: Account name from list_accounts. folder: Folder to search (default "INBOX"); use list_folders or resolve_folder for others. from_: Substring of the From header (name or address). to: Substring of the To header. cc: Substring of the Cc header. subject: Substring of the Subject. body: Substring of the message body. text: Substring of headers or body. since: Only messages on or after this date (YYYY-MM-DD). before: Only messages before this date (YYYY-MM-DD). unseen: Only unread messages. seen: Only read messages. flagged: Only flagged/starred messages. has_attachment: Best-effort filter for messages with attachments (multipart/mixed or an attachment disposition header). raw: A raw IMAP SEARCH string, e.g. 'OR FROM "alice" FROM "bob"'. When set, every other filter is ignored. limit: Maximum number of results (default 50).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| cc | No | ||
| to | No | ||
| raw | No | ||
| body | No | ||
| seen | No | ||
| text | No | ||
| from_ | No | ||
| limit | No | ||
| since | No | ||
| before | No | ||
| folder | No | INBOX | |
| unseen | No | ||
| account | Yes | ||
| flagged | No | ||
| subject | No | ||
| has_attachment | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |