count_messages
Get the number of messages in a folder that match your search criteria. Returns a simple count quickly without fetching full message details.
Instructions
Count messages in a folder matching optional search criteria. Returns just a number (no envelopes fetched). The attachment filters (hasAttachment, attachmentName, attachmentType) are rejected here — they require an envelope scan that defeats the count's speed promise. Use search_messages for attachment-based filtering. A non-selectable namespace container (e.g. Folders/Labels) is rejected with an actionable error rather than returning 0.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| folder | No | Folder to count in (default: INBOX). A non-selectable namespace container like `Folders`/`Labels` is rejected. | INBOX |
| match | No | Optional search criteria to narrow the count (same fields as search_messages: from, to, subject, body, since, before, seen, flagged, larger, smaller, listId). Attachment filters are NOT allowed here — use search_messages for those. Omit to count every message in the folder. |