export
Export emails to file formats (MIME, Markdown, JSON, CSV) for archival, forensics, or programmatic processing. Supports single messages, batch search results, or full conversations.
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 |
|---|---|---|---|
| id | No | Email ID (target=message/mime, required) | |
| order | No | Message order (target=conversation, default: chronological) | |
| query | No | Free-text search shortcut (target=messages). Equivalent to passing searchQuery: { subject: <query> }. Convenience alias for callers used to search-emails. | |
| base64 | No | Return base64 encoded (target=mime) | |
| 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). | |
| target | No | Export target (default: message) | |
| maxSize | No | Max content size in bytes (target=mime, default: 1MB) | |
| emailIds | No | Email IDs to export (target=messages) | |
| savePath | No | File path or directory (target=message) | |
| outputDir | No | Output directory (target=messages/conversation, required) | |
| headersOnly | No | MIME headers only, no body (target=mime) | |
| searchQuery | No | Search query to find emails (target=messages, alternative to emailIds) | |
| conversationId | No | Conversation ID (target=conversation, required) | |
| includeAttachments | No | Include attachments (default: true for single, false for batch) |