Open an attachment
mail_get_attachmentDownload an email attachment, save it to disk, and return extracted text or image content; OCR handles scans and photos, other file types return the saved path.
Instructions
Downloads an attachment of a received message, saves it to disk and returns its content: text for text files, the text of every page for PDFs, the picture for images. Scans (PDF pages without a text layer) and photos of documents are read through OCR, tables included; pages that came from OCR are marked “(OCR)” — treat numbers from them with some caution and ask for a preview when a figure matters. Other types (docx, xlsx, zip…) only return the path of the saved file. Pick the attachment by name or by its number from the list in mail_get_email; a message with a single attachment needs neither. The message itself is not changed.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| id | Yes | Message id (from mail_search_emails / mail_get_email). | |
| ocr | No | false = do not send scans and photos to the OCR provider, return the image only. | |
| account | No | Which account: leave empty for the signed-in mailbox, or name a shared mailbox / group you have access to (the part before @ is enough; a full address works too). mail_list_mailboxes shows what exists. | |
| page_to | No | PDF: last page to return (default: the last one). | |
| preview | No | PDF: also attach an image of page 1 (chart, stamp, signature, checking the OCR). | |
| save_dir | No | Folder to save the file to; default /root/Downloads/Mail-Attachments. | |
| page_from | No | PDF: first page to return (default 1). | |
| attachment | No | Attachment name (a part is enough, e.g. “invoice”) or its number starting at 1. |