Skip to main content
Glama

Export Emails

export
Destructive

Save 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

NameRequiredDescriptionDefault
idNoEmail ID (target=message/mime, required)
emailNoAlias for `sharedMailbox`.
orderNoMessage order (target=conversation, default: chronological)
queryNoFree-text search shortcut (target=messages). Equivalent to passing searchQuery: { subject: <query> }. Convenience alias for callers used to search-emails.
base64NoReturn base64 encoded (target=mime)
formatNoExport 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).
targetNoExport target (default: message)
maxSizeNoMax content size in bytes (target=mime, default: 1MB)
emailIdsNoEmail IDs to export (target=messages). At most 100 per call: any beyond the first 100 are left out, and the result says how many.
savePathNoAbsolute 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.
outputDirNoAbsolute 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.
overwriteNoReplace 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.
headersOnlyNoMIME headers only, no body (target=mime)
searchQueryNoSearch to find emails (target=messages, alternative to emailIds)
sharedMailboxNoEmail 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).
conversationIdNoConversation ID (target=conversation, required)
includeAttachmentsNoInclude attachments (default: true for single, false for batch)

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed14 schema fields changedv3.14.1
    • addedInput schema / properties / email
      Added value: +{
      +  "description": "Alias for `sharedMailbox`.",
      +  "type": "string"
      +}
    • changedInput schema / properties / emailIds / description
      Previous value: -"Email IDs to export (target=messages)"New value: +"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."
    • changedInput schema / properties / format / description
      Previous value: -"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)."New value: +"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)."
    • changedInput schema / properties / outputDir / description
      Previous value: -"Output directory (target=messages/conversation, required)"New value: +"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."
    • addedInput schema / properties / overwrite
      Added value: +{
      +  "description": "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.",
      +  "type": "boolean"
      +}
    • changedInput schema / properties / savePath / description
      Previous value: -"File path or directory (target=message)"New value: +"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."
    • changedInput schema / properties / searchQuery / description
      Previous value: -"Search query to find emails (target=messages, alternative to emailIds)"New value: +"Search to find emails (target=messages, alternative to emailIds)"
    • addedInput schema / properties / searchQuery / properties / folder / description
      Added value: +"Folder to search (default: inbox): a well-known name, display name, `Parent/Child` path or folder ID"
    • addedInput schema / properties / searchQuery / properties / from / description
      Added value: +"Sender address or name to match (Graph `$search`)"
    • addedInput schema / properties / searchQuery / properties / maxResults / description
      Added value: +"Most messages to export (default: 25, max: 100 per call). Newest first, or by relevance when `from`/`subject` is set."
    • addedInput schema / properties / searchQuery / properties / receivedAfter / description
      Added value: +"Only messages received at or after this date/time (ISO 8601)"
    • addedInput schema / properties / searchQuery / properties / receivedBefore / description
      Added value: +"Only messages received at or before this date/time (ISO 8601)"
    • addedInput schema / properties / searchQuery / properties / subject / description
      Added value: +"Subject text to match (Graph `$search`)"
    • addedInput schema / properties / sharedMailbox
      Added value: +{
      +  "description": "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).",
      +  "type": "string"
      +}
  2. Changed3 schema fields changedv3.7.4
    • addedInput schema / additionalProperties
      Added value: +false
    • changedInput schema / properties / format / description
      Previous value: -"Export format (target=message: mime/eml/markdown/json/csv, target=conversation: eml/mbox/markdown/json/html/csv)"New value: +"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)."
    • addedInput schema / properties / query
      Added value: +{
      +  "description": "Free-text search shortcut (target=messages). Equivalent to passing searchQuery: { subject: <query> }. Convenience alias for callers used to search-emails.",
      +  "type": "string"
      +}
  3. First observedv3.4.1

TDQS

A4.6/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

Annotations declare destructiveHint=true, readOnlyHint=false and idempotentHint=false, and the description adds substantial context beyond them: files are only written inside temp/~/Downloads/~/Documents/OUTLOOK_EXPORT_DIR, dot-prefixed names and symlinks/hardlinks are never replaced, directories are created if missing, batch caps at 100, and sharedMailbox requires delegate access plus OUTLOOK_SHARED_MAILBOX opt-in or the call is refused.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

A single dense paragraph, but it is front-loaded with the default target and each clause is scoped by `target=` markers, so it scans predictably. No filler sentences, though the length is near the upper bound for readability.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

For a 17-parameter, zero-required tool with no output schema, the description covers every target's required inputs, defaults, limits, path safety rules, and the shared-mailbox prerequisite. Nothing needed to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100%, so baseline is 3, but the description adds cross-parameter semantics the schema states only piecemeal: format validity varies by target, includeAttachments defaults differ between single and batch, and savePath directory-vs-file resolution rules (path ending in `/` is created and given a unique name).

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

States a specific verb (export) and resource (emails to files) and enumerates the four distinct target modes with what each produces. An agent can tell immediately that this writes email content to disk, distinct from read-email or search-emails.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines4/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

Gives clear per-target usage: which parameters apply to message vs messages vs conversation vs mime, and that emailIds and searchQuery/query are alternatives for batch. It even notes `query` is a convenience alias for callers used to search-emails. It never explicitly says when to prefer this over read-email for simple viewing, so it stops short of full sibling routing.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.