Save Attachments
Saves the attachments of an email.
Common Properties
- Name - The custom name of the node.
- Color - The custom color of the node.
- Delay Before (sec) - Waits in seconds before executing the node.
- Delay After (sec) - Waits in seconds after executing node.
- Continue On Error - Automation will continue regardless of any error. The default value is false.
info
If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.
Input
- Client Id - The client id. The ID is created by the Connect node.
- Mail Folder - The mail folder where the email with attachments is located. The default value is INBOX.
- Download Path - The path where to download the attachments.
- Email Unique ID (Uid) - The unique identifier of the email.
Output
- Messages - Array containing the downloaded attachments.
Options
- Credentials - The stored credentials to access the email service. Required if there is no Client Id.
How It Works
The Save Attachments node downloads email attachments to local storage. Here's the process:
- Authentication - Uses Client ID or direct credentials
- Folder Selection - Selects the mailbox folder containing the email
- Email Retrieval - Fetches the specific email by UID
- Attachment Parsing - Identifies and extracts all attachments
- File Saving - Saves each attachment to the specified download path
- Return Paths - Returns array of saved file paths
Requirements
- Client ID from Connect node OR Credentials from vault
- Mail Folder - Folder containing the email
- Download Path - Valid local directory path (must exist)
- Email Unique ID (Uid) - UID of email with attachments
Error Handling
| Error Code | Description | Resolution |
|---|---|---|
| Core.Mail.SaveAttachments.ErrOnCreate | Config parse error | Check node configuration |
| Core.Mail.ErrCredentials | Invalid credentials | Verify vault credentials |
| Core.Mail.SaveAttachments.ErrPath | Download path is empty | Provide valid download path |
| Core.Mail.SaveAttachments.ErrFolder | Mail folder is empty | Provide folder name |
| Core.Mail.Attachments.ErrClientId | Client ID not found | Ensure Connect node executed |
| Core.Mail.SaveAttachments.ErrSelect | Cannot select folder | Verify folder exists |
| Core.Mail.SaveAttachments.ErrBody | Cannot read email body | Email may be corrupted |
| Core.Mail.SaveAttachments.ErrWrite | Cannot write file | Check download path permissions |
| Core.Mail.SaveAttachments.ErrUidFetch | Cannot fetch email | Verify UID is valid |
| Core.Mail.ErrConn | Connection missing | Ensure Connect executed |
Usage Examples
Example 1: Save All Attachments from Email
{
"client_id": "{{client_id}}",
"mail_folder": "INBOX",
"email_uid": 12345,
"download_path": "C:\\Downloads\\EmailAttachments"
}
// Output: ["C:\\Downloads\\EmailAttachments\\invoice.pdf", "C:\\Downloads\\EmailAttachments\\report.xlsx"]
Example 2: Process Attachments from Multiple Emails
// Get emails with attachments
var emails = {{messages}};
// Save attachments from each
for (var email of emails) {
if (email.attachments && email.attachments.length > 0) {
// Use Save Attachments node with email.uid
// Download to: C:\\ProcessedAttachments\\{{email.subject}}
}
}
Example 3: Organized Attachment Storage
// Search for invoices
var invoices = {{search_results}};
// Save to dated folders
for (var email of invoices) {
var date = new Date(email.date * 1000);
var folder = `C:\\Invoices\\${date.getFullYear()}\\${date.getMonth()+1}`;
// Use Save Attachments with dynamic folder path
}
Usage Notes
- Download Path Must Exist: Create the directory before using this node
- File Naming: Attachments use their original filenames (sanitized for filesystem safety)
- Duplicate Names: Files with same name are overwritten
- All Attachments: Saves all attachments from the email (no selective download)
- Embedded Images: May include embedded images from HTML emails
- File Permissions: Download path must have write permissions
- Path Format: Use OS-appropriate path format (Windows: C:\path, Linux: /path)
Tips
- Create Folders First: Use File System nodes to create download path
- Unique Naming: Include email UID or date in folder path to avoid overwrites
- Check Attachments First: Use Get Mail to preview attachment list before downloading
- Batch Processing: Process emails in batches to manage disk space
- File Validation: Verify downloaded files exist and have expected size
- Cleanup: Delete old attachments after processing to save space
Related Nodes
- Get Mail - Preview attachment list
- Search Mail - Find emails with attachments
- Connect - Establish connection