Gmail — Download attachments
Gmail — Download attachments
Section titled “Gmail — Download attachments”Type: gmail-download-attachments · Package: Gmail v1.0.4 · Output: List<string>
Downloads all the attachments of an email to a folder on the machine and returns the list of saved paths. It is the usual step after searching for emails with has:attachment.
How it works
Section titled “How it works”It works on the session created with Gmail — Connect. Pass it in the session parameter, or place this activity inside the body of Gmail — Connect to inherit it automatically.
- The destination folder is created if it doesn’t exist (including intermediate folders).
- It downloads every part of the email that has a file name, including embedded images that carry one (logos, signatures). They are the same items listed in the
attachmentskey of Get email by ID. - 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. Running the activity twice on the same email gives you numbered copies.
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 | ZoanGmailSession | — | Gmail — Connect session (inherited inside body). |
Output
Section titled “Output”Returns a List<string> with the full path of each saved file, in the order they appear in the email. Loop over it with For each or access an item by index (paths[0]) to process it, for example opening it with Excel or reading it. If the email had no attachments, the list is empty (it does not fail).
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. |
Requested entity was not found. | No email with that ID exists in the mailbox. |
| Folder access error | The robot cannot create or write to folder (Windows permissions, missing drive). |
Example
Section titled “Example”Gmail — Connect credential = credential("gmail-invoices") └─ body: Gmail — Get emails query = "is:unread has:attachment filename:pdf subject:invoice" → output: emails For each email in emails └─ Gmail — Download attachments id = email["id"] folder = "C:\invoices\inbox" → output: files For each path in files └─ PDF Get Text path = path → output: text Gmail — Apply label id = email["id"] labels = "Processed"Related activities
Section titled “Related activities”- Gmail — Get emails — find emails with attachments.
- Gmail — Get email by ID — see the email’s data and attachments.
- Gmail — Reply — reply to the sender.
- All Gmail activities