Outlook 365 — Download attachments
Outlook 365 — Download attachments
Section titled “Outlook 365 — Download attachments”Type: outlook365-download-attachments · Package: Outlook 365 v1.0.4 · Output: List<string>
Downloads an email’s file attachments to a folder on the machine and returns the list of saved paths. It is the usual step after searching for emails with attachments.
How it works
Section titled “How it works”It works on the session created with Outlook 365 — Connect. Pass it in the session parameter, or place this activity inside the body of Outlook 365 — Connect to inherit it automatically.
- The destination folder is created if it doesn’t exist (including intermediate folders).
- Each file is saved with its original name. It never overwrites: if a file with that name already exists, it saves
name (1).ext,name (2).ext, and so on. So running the activity twice on the same email gives you numbered copies. - It downloads file attachments, including images embedded in the body (logos, signatures). Attached emails (a
.msginside the email) and attachments that are OneDrive/SharePoint links are skipped.
To know beforehand whether an email has attachments, check its hasAttachments key or filter with filter = "hasAttachments eq true" in Get emails.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
id | string | — | Message ID. |
folder | string | — | Destination folder. Created if it doesn’t exist. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanOutlookMailSession | — | Outlook 365 — Connect session (inherited inside body). |
Output
Section titled “Output”Returns a List<string> with the full path of each saved file, in the order Graph lists the attachments. If the email had no file attachments, the list is empty (it does not fail). Loop over it with For each or access an item by index (paths[0]).
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'id' is required. | id is empty or the expression returned null. |
'folder' is required. | folder is empty or the expression returned null. |
Graph error ErrorItemNotFound | No email exists with that ID anymore (deleted or moved). Download before moving. |
| Folder access error | The robot cannot create or write to folder (Windows permissions, missing drive). |
Example
Section titled “Example”Outlook 365 — Connect credential = credential("m365-invoices") └─ body: Outlook 365 — Get emails folder = "inbox" filter = "hasAttachments eq true and isRead eq false" → output: emails For each email in emails └─ Outlook 365 — Download attachments id = email["id"] folder = "C:\invoices\inbox" → output: files For each path in files └─ PDF Get Text path = path → output: text Outlook 365 — Mark read/unread id = email["id"]Related activities
Section titled “Related activities”- Outlook 365 — Get emails — find emails with attachments.
- Outlook 365 — Get email by ID — see the email’s data.
- Outlook 365 — Move — archive the processed email.
- All Outlook 365 activities