imap_download_attachment
Download attachments from emails by specifying folder, UID, and filename. Images display inline, PDF text extracts automatically, other files save to downloads directory.
Instructions
Download a single attachment from an email (folder + uid + attachment filename/contentId, as listed by imap_get_email). Images are returned inline for viewing; PDFs are saved and their text is extracted inline (extractText); other files are saved to the shared downloads directory (or savePath). Use when the user wants the actual file contents, not just the message body.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| uid | Yes | Email UID | |
| folder | No | Folder name | INBOX |
| filename | Yes | Attachment filename or contentId | |
| savePath | No | Optional file path to save the attachment to. If not provided, files are saved to the shared downloads directory. | |
| accountId | No | Account ID (from imap_list_accounts). Optional if accountName is given or only one account is configured. | |
| accountName | No | Account name instead of accountId. Optional if accountId is given or only one account is configured. | |
| extractText | No | For PDFs, extract and return text content inline |