export
Export emails to multiple file formats for archival, forensics, or programmatic processing. Supports single messages, batch exports, full conversations, or raw MIME bytes.
Instructions
Export emails to file formats for archival, forensics, or programmatic processing. target=message (default) exports a single email by id to savePath — accepts mime/eml/markdown/json/csv. target=messages batch-exports either an explicit emailIds array or messages matching searchQuery (or query shortcut) into outputDir — accepts markdown/json/csv. target=conversation exports a full thread by conversationId into outputDir (chronological by default; pass order: "reverse" for newest-first) — accepts eml/mbox/markdown/json/html/csv. target=mime returns raw RFC-822 MIME bytes for id (use headersOnly for just headers, base64 for encoded transport, maxSize to cap at default 1MB). includeAttachments defaults to true for single-message exports and false for batch. Format support varies by target — see the format param enum.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| target | No | Export target (default: message) | |
| id | No | Email ID (target=message/mime, required) | |
| format | No | Export format. Valid values vary by target: target=message accepts mime/eml/markdown/json/csv (mbox and html are conversation-only). target=conversation accepts eml/mbox/markdown/json/html/csv. target=messages (batch) accepts markdown/json/csv. mime is an alias for eml (same RFC822 bytes, .eml extension on disk). | |
| savePath | No | File path or directory (target=message) | |
| includeAttachments | No | Include attachments (default: true for single, false for batch) | |
| emailIds | No | Email IDs to export (target=messages) | |
| searchQuery | No | Search query to find emails (target=messages, alternative to emailIds) | |
| query | No | Free-text search shortcut (target=messages). Equivalent to passing searchQuery: { subject: <query> }. Convenience alias for callers used to search-emails. | |
| outputDir | No | Output directory (target=messages/conversation, required) | |
| conversationId | No | Conversation ID (target=conversation, required) | |
| order | No | Message order (target=conversation, default: chronological) | |
| headersOnly | No | MIME headers only, no body (target=mime) | |
| base64 | No | Return base64 encoded (target=mime) | |
| maxSize | No | Max content size in bytes (target=mime, default: 1MB) |