Skip to main content
How-To Guides Last updated: 6 March 2026

How to Work with Attachments

List, view, and download email attachments to your local machine.

List the attachments on an email, preview their content, or download them to disk.

List Attachments

“What attachments does that email have?”

tool: attachments
params:
  messageId: "AAMkAGR..."
  action: "list"

Returns the name, size, content type, and ID of each attachment.

View Attachment Content

Preview an attachment’s content inline (works best for text, markdown, and simple documents):

tool: attachments
params:
  messageId: "AAMkAGR..."
  action: "view"
  attachmentId: "AAMkAGR-att1..."

Download an Attachment

“Download the PDF from that email to /tmp”

tool: attachments
params:
  messageId: "AAMkAGR..."
  action: "download"
  attachmentId: "AAMkAGR-att1..."
  savePath: "/tmp/"

The file is saved with its original filename to the specified directory.

Download All Attachments

List the attachments first, then download each one:

“Download all attachments from that email to /tmp/attachments/”

The attachments will be listed, then downloaded sequentially.

Parameter Reference

ParameterWhat it doesRequired
messageIdThe email containing the attachmentYes
actionlist, view, or downloadNo (default: list)
attachmentIdSpecific attachment IDYes for view/download
savePathDirectory to save toNo (default: current directory)

Tips

  • Use list first to see attachment names and IDs before downloading
  • view works well for text-based files (.txt, .csv, .md) — binary files need download
  • Find emails with attachments using search-emails with hasAttachments: true
Was this helpful?

Related Articles