Skip to main content

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:

  1. Authentication - Uses Client ID or direct credentials
  2. Folder Selection - Selects the mailbox folder containing the email
  3. Email Retrieval - Fetches the specific email by UID
  4. Attachment Parsing - Identifies and extracts all attachments
  5. File Saving - Saves each attachment to the specified download path
  6. 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 CodeDescriptionResolution
Core.Mail.SaveAttachments.ErrOnCreateConfig parse errorCheck node configuration
Core.Mail.ErrCredentialsInvalid credentialsVerify vault credentials
Core.Mail.SaveAttachments.ErrPathDownload path is emptyProvide valid download path
Core.Mail.SaveAttachments.ErrFolderMail folder is emptyProvide folder name
Core.Mail.Attachments.ErrClientIdClient ID not foundEnsure Connect node executed
Core.Mail.SaveAttachments.ErrSelectCannot select folderVerify folder exists
Core.Mail.SaveAttachments.ErrBodyCannot read email bodyEmail may be corrupted
Core.Mail.SaveAttachments.ErrWriteCannot write fileCheck download path permissions
Core.Mail.SaveAttachments.ErrUidFetchCannot fetch emailVerify UID is valid
Core.Mail.ErrConnConnection missingEnsure 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