Export Emails
exportSave one Outlook email, a batch, or a full conversation to files in EML, MIME, Markdown, JSON, CSV, HTML, or MBOX.
Instructions
Export emails to files. target=message (default) exports one email by id (mime/eml/markdown/json/csv) to savePath: a directory (or a path ending in /, created if missing) gets a new, unique file name; a file path is created new and an existing file is replaced only with overwrite: true. target=messages batch-exports emailIds, or matches for searchQuery/query, into outputDir, at most 100 messages per call. target=conversation exports a thread (up to 1000 messages) by conversationId into outputDir (eml/mbox/markdown/json/html/csv; order: "reverse" for newest first). target=mime returns raw RFC-822 MIME for id (headersOnly, base64, maxSize, default 1MB). Files are written only inside the system temp directory (the default), ~/Downloads, ~/Documents or OUTLOOK_EXPORT_DIR, never to dot-prefixed names. Pass sharedMailbox (alias email) when the ids come from a shared mailbox. includeAttachments defaults to true for one message, false for batch.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | No | Email ID (target=message/mime, required) | |
| No | Alias for `sharedMailbox`. | ||
| 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 mime/eml/markdown/json (one file per message) or csv (one file). 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). At most 100 per call: any beyond the first 100 are left out, and the result says how many. | |
| savePath | No | Absolute file path or directory, or one starting with ~/ (target=message). Relative paths are refused. Must be inside the system temp directory, ~/Downloads, ~/Documents or OUTLOOK_EXPORT_DIR. An existing file is not replaced unless overwrite is true. | |
| outputDir | No | Absolute output directory, or one starting with ~/ (target=messages, required; target=message/conversation, default: system temp directory). Must be inside the system temp directory, ~/Downloads, ~/Documents or OUTLOOK_EXPORT_DIR. | |
| overwrite | No | Replace an existing file at savePath (target=message, default: false). Never replaces a symlink, a hard-linked file, a dotfile, or a file in a dot-directory below the allowed folder. | |
| headersOnly | No | MIME headers only, no body (target=mime) | |
| searchQuery | No | Search to find emails (target=messages, alternative to emailIds) | |
| sharedMailbox | No | Email address of a shared/delegated mailbox to export from (default: the signed-in account). Applies to all targets (message/messages/conversation/mime) — pass it whenever the id(s)/conversationId/searchQuery belong to a shared mailbox. Requires delegate access + Mail.Read.Shared. Work/school only; needs the server opt-in setting OUTLOOK_SHARED_MAILBOX (otherwise the call is refused with setup guidance). | |
| conversationId | No | Conversation ID (target=conversation, required) | |
| includeAttachments | No | Include attachments (default: true for single, false for batch) |