Skip to main content

Get Mail

Retrieves emails from a specified mailbox.

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 the ContinueOnError property is set to true, no error will be caught and the automation will continue running. If a Catch node is used, it will have no effect.

Input

  • Client Id - The id of the client. The ID is created by the Connect node.
  • Mail Folder - The mailbox folder to search for emails. The default value is INBOX.
  • Number of Messages - The maximum number of messages to retrieve.

Output

  • Messages - The messages retrieved from the specified mailbox.

Options

  • Credentials - The credentials to use to authenticate the mailbox. Required if there is no Client Id.
  • Mark as Read - If set to true, all retrieved emails will be marked as read.
  • Only Unread - If set to true, only unread emails will be retrieved from the mailbox.

Automatic credentials are provided for authenticated mailboxes. You do not need to provide these credentials.

How It Works

The Get Mail node retrieves emails from a mailbox using the IMAP protocol. Here's the step-by-step process:

  1. Authentication - Uses either Client ID from Connect node or direct credentials
  2. Folder Selection - Selects the specified mailbox folder (default: INBOX)
  3. Email Filtering - If "Only Unread" is enabled, filters for unread messages
  4. Message Retrieval - Fetches the most recent N messages (specified by Number of Messages)
  5. Content Parsing - Parses email headers, body (plain text and HTML), and attachment information
  6. Mark as Read - If enabled, marks retrieved emails as read
  7. Return Results - Returns array of message objects with all email data

Requirements

To use the Get Mail node, you need:

  • Client ID from Connect node OR Credentials from vault with IMAP access
  • Mail Folder - Valid folder name (e.g., "INBOX", "Sent", "Archive")
  • Number of Messages - Must be greater than 0
  • IMAP Access - Credentials must have IMAP server settings configured

Error Handling

Error CodeDescriptionResolution
Core.Mail.Get.ErrOnCreateConfiguration parsing failedCheck node configuration
Core.Mail.Get.ErrCredentialsInvalid or missing credentialsVerify vault credentials are selected
Core.Mail.Get.ErrFolderFolder name is emptyProvide a valid folder name
Core.Mail.Get.ErrTopNumber of messages must be > 0Set Number of Messages to at least 1
Core.Mail.Get.ErrClientIdClient ID not foundEnsure Connect node executed successfully
Core.Mail.Get.ErrSelectCannot select mailbox folderVerify folder name exists
Core.Mail.Get.ErrBodyCannot read email bodyEmail may be corrupted or access denied
Core.Mail.Get.ErrListCannot list mailboxesCheck IMAP connection and permissions
Core.Mail.Get.ErrSearchSearch for unread emails failedCheck IMAP server supports search
Core.Mail.Get.ErrMarkReadCannot mark emails as readCheck write permissions on folder
Core.Mail.ErrConnConnection missingEnsure Connect node was executed or credentials provided

Usage Examples

Example 1: Get Latest 10 Emails from INBOX

// Using Client ID from Connect node
{
"client_id": "{{client_id}}",
"mail_folder": "INBOX",
"number_of_messages": 10,
"mark_as_read": false,
"only_unread": false
}

// Output: Array of 10 most recent emails
// Each email contains: uid, subject, from, to, cc, bcc, date, body, attachments

Example 2: Get Only Unread Emails

{
"client_id": "{{client_id}}",
"mail_folder": "INBOX",
"number_of_messages": 50,
"mark_as_read": true, // Mark as read after retrieving
"only_unread": true // Only get unread emails
}

// Output: Array of up to 50 unread emails (marked as read)
// Useful for processing new emails in automation

Example 3: Process Emails from Sent Folder

{
"client_id": "{{client_id}}",
"mail_folder": "Sent",
"number_of_messages": 20,
"mark_as_read": false,
"only_unread": false
}

// Retrieves last 20 sent emails
// Useful for auditing or tracking sent communications

Example 4: Get Emails and Process Attachments

// Get emails with attachments
var emails = {{messages}}; // Output from Get Mail

// Loop through emails
for (var email of emails) {
console.log("Subject:", email.subject);
console.log("From:", email.from);
console.log("Attachments:", email.attachments);
console.log("Mailbox UID:", email.mailbox_uid); // Format: "INBOX/12345"

// Use mailbox_uid for Save Attachments, Move, Delete, or Reply
}

Usage Notes

  • Message Ordering: Emails are retrieved in reverse chronological order (newest first)
  • Number of Messages: Specifies maximum emails to retrieve. If folder has fewer emails, returns all available
  • Body Content: Node returns both plain text and HTML versions when available. Plain text is preferred if available
  • Attachment Details: Returns attachment filenames in attachments array (actual files not downloaded until Save Attachments node)
  • Mailbox UID: Each email has a mailbox_uid in format "FOLDER/UID" for use with other nodes (Move, Delete, Reply)
  • Only Unread Filter: When enabled, retrieves only unread emails up to the specified limit
  • Mark as Read: Marks emails as read in the order they were retrieved
  • Empty Folder: Returns empty array if folder has no messages
  • Folder Names: Case-sensitive. Use exact folder names (check with List Folders node)
  • OAuth2 Compatibility: Works with both Basic and OAuth2 authentication

Message Object Structure

{
"uid": 12345, // Email unique ID
"mailbox_uid": "INBOX/12345", // Format for other nodes
"message_id": "<id@server.com>", // RFC Message-ID
"subject": "Email Subject",
"from": "sender@example.com",
"to": ["recipient@example.com"],
"cc": ["cc@example.com"],
"bcc": [],
"date": 1640000000, // Unix timestamp
"body": "Email body text", // Preferred body (plain or HTML)
"body_plain": "Plain text", // Plain text version
"body_html": "<html>...</html>", // HTML version
"attachments": ["file1.pdf", "image.jpg"], // Attachment filenames
"has_inline_images": false // True if HTML email has embedded images
}

Tips

  • Process in Batches: For large mailboxes, retrieve emails in batches to avoid memory issues
  • Use Only Unread: Set "Only Unread" to true for automation that processes new emails
  • Mark as Read: Enable "Mark as Read" to track processed emails in automation workflows
  • Save Mailbox UID: Store mailbox_uid to reference emails in subsequent nodes (Reply, Move, Delete)
  • Error Handling: Use Try-Catch to handle cases where folder doesn't exist or is empty
  • Performance: Retrieving fewer messages is faster. Start with lower numbers and increase as needed
  • Folder Structure: Use List Folders node first to discover exact folder names
  • Attachment Preview: Check attachments array to see what files are attached before downloading
  • Threading: Use message_id for email threading and conversation tracking
  • Date Filtering: For date-based retrieval, use Search Mail node instead