mail. read_ attachment
Download an attachment from an email.
2 credits. Per call.
Example prompt
Send this to your AI app when Heelo is connected:
Get the PDF attached to that invoice email
Input fields
| Field | Type | Description |
|---|---|---|
message_idRequired | string | Message id, as returned by mail.read_list. |
attachment_idRequired | string | Attachment id, as returned by mail.read_get. |
account_handle | string | Which configured mailbox to read. |
folder | string | Folder that holds the message. |
end_user_id | string | Optional end-user scope. |
Output fields
The fields in data when status is success.
| Field | Type |
|---|---|
message_id | string |
attachment_id | string |
filename | string |
content_type | string |
size_bytes | integer |
bytes_read | integer |
streamed | boolean |
content_encoding | string |
content_base64 | string |
note | string |
account | object |
Code
The call with the input fields that the tool needs. Replace each word in capitals, such as MESSAGE_ID. Set HEELO_API_KEY to your API key.
import os
import requests
response = requests.post(
"https://toolsprimitives.uk/v1/tools/mail.read_attachment/invoke",
headers={"Authorization": f"Bearer {os.environ['HEELO_API_KEY']}"},
json={"input": {
"message_id": "MESSAGE_ID",
"attachment_id": "ATTACHMENT_ID",
}},
timeout=120,
)
response.raise_for_status()
print(response.json())// Node.js 18 or newer, in an ES module.
const response = await fetch("https://toolsprimitives.uk/v1/tools/mail.read_attachment/invoke", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.HEELO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
input: {
"message_id": "MESSAGE_ID",
"attachment_id": "ATTACHMENT_ID"
},
}),
signal: AbortSignal.timeout(120_000),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
console.log(await response.json());