Outlook Get Attachments
Outlook Get Attachments
Section titled “Outlook Get Attachments”Type: outlook-get-attachments · Package: Outlook Activities v1.0.4 · Output: List<string>
Saves the attachments of an email to a local folder and returns the list of paths of the saved files. It is key in processes that receive documents by email: PDF invoices, Excel spreadsheets, etc.
How it works
Section titled “How it works”Given the EntryID of an email (the .Id returned by Outlook Get Emails), it saves all its attachments to outputDir with their original names and returns the resulting paths. Then you process those files with the matching package (Excel, PDF…).
- If
outputDirdoes not exist, it is created (including intermediate folders). - If a file with the same name already exists, it is overwritten. If two attachments of the same email share a name, the last one wins. To keep emails apart, use one folder per email (for example with the received date in the path).
- Every attachment of the email is saved, including images embedded in the body, if any.
- The email is not modified.
Required parameters
Section titled “Required parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
entryId | string | — | EntryID of the email (from email.Id). |
outputDir | string | — | Local folder where attachments are saved. Created if missing. |
Optional parameters
Section titled “Optional parameters”| Parameter | Type | Default | Description |
|---|---|---|---|
session | ZoanOutlookSession | — | Session from Outlook Connect. Inherited inside the Connect body; without a session the default account is used. |
Output
Section titled “Output”Returns a List<string> with the full path of each saved file (outputDir + attachment name), in the order they appear in the email. If the email has no attachments, it returns an empty list.
Common errors
Section titled “Common errors”| Message | Cause and fix |
|---|---|
'entryId' is required. / 'outputDir' is required. | The parameter is missing or the expression returned null. Check the email variable. |
| Outlook error when opening the item | The EntryID does not belong to an email in this profile (it was moved to another mailbox, deleted, or comes from another account). Use the .Id from a recent read. |
| Path access error | The robot cannot write to outputDir. Use a folder with write permissions. |
Example
Section titled “Example”Save the attachments of each email in its own folder and process the spreadsheets:
For Each items = emails itemVariable = email └─ activities: Outlook Get Attachments entryId = email.Id outputDir = pathJoin("C:/invoices", email.SentAt.ToString("yyyyMMdd-HHmmss")) → output: files For Each items = files itemVariable = file └─ activities: If condition = file.EndsWith(".xlsx") └─ then: Read Excel Sheet path = file → output: data ... process ...Related activities
Section titled “Related activities”- Outlook Get Emails — get the emails (and their EntryIDs).
- List Files — check what ended up in the folder.