Search mail messages
mail_search_messagesSearch Outlook messages by text and return compact results in one call. Use no date range for relevance-ranked full-text search, or add after/before to filter by received date.
Instructions
Finds messages by text, returning the same compact projection as mail_list_messages, 10 per call by default (50 max). Two modes, because Graph will not combine them: with no date range it uses $search, a relevance-ranked KQL search over subject, body and participants (results are NOT in date order, and $search supports no date syntax). Passing after or before switches to $filter on receivedDateTime, which sorts newest-first but can only match query as a substring of the subject — body text is not searched in that mode. The response reports which mode ran. To search body text within a period, search first and filter the dates yourself.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| to | No | Only messages addressed to this exact address. | |
| top | No | How many messages to return. Defaults to 10; 50 is the ceiling. | |
| from | No | Only messages sent by this exact address. | |
| after | No | Only messages received at or after this ISO-8601 date or datetime, e.g. "2026-01-01" or "2026-01-01T09:00:00Z". A bare date starts at 00:00:00Z. Supplying this switches the tool to $filter mode. | |
| query | Yes | Words to look for. Without a date range this is a KQL search across subject, body, and participants, so "subject:budget" or "quarterly review" both work. With after/before it degrades to a subject substring match — see the tool description. | |
| before | No | Only messages received at or before this ISO-8601 date or datetime. A bare date ends at 23:59:59Z that day. Supplying this switches the tool to $filter mode. | |
| hasAttachments | No | Only messages with (or without) attachments. | |
| includeWebLink | No | Include each row's Outlook webLink. Off by default: a webLink is the message id all over again, URL-encoded, and on a 50-row page it costs more than every subject and preview put together. Turn it on only when you need a link a person will click — to read or act on a message, pass its `id` to another mail tool instead. |