Skip to content

IMAP

IMAP stands for Internet Message Access Protocol, which is the standard protocol used for accessing and managing email messages stored on a mail server. Unlike SMTP which only sends emails, IMAP allows you to read, search, organize, and manage your emails directly on the server.

Key Features of IMAP:

  • Email Reading: Retrieve and read email messages from any mailbox folder
  • Email Management: Mark emails as read/unread, delete, or move between folders
  • Search Capabilities: Search emails by sender, subject, body content, or read status
  • Attachment Handling: Download and process email attachments
  • Folder Access: Access any mailbox folder (Inbox, Sent, Drafts, custom folders)
  • Real-time Monitoring: Trigger workflows when new emails arrive
  • Filtered Triggers: Monitor for emails matching specific criteria (sender, subject, attachments)
  • Batch Processing: Handle multiple emails efficiently in a single operation
  • TLS/SSL Support: Secure connections with encryption (port 993 for TLS, 143 for non-TLS)

Further information

Read more detailed information on IMAP here.

Triggers:

New Email: Triggers when a new unread email is received in the specified mailbox.

New Email Matching Criteria: Triggers when a new email matching specific filters (sender, subject, body, attachments) is received.

Actions:

  • Read Email: Retrieve the full content of a specific email by UID
  • Mark Email as Read: Mark one or more emails as read
  • Mark Email as Unread: Mark one or more emails as unread
  • Delete Email: Permanently delete one or more emails
  • Move Email: Move emails from one folder to another
  • Search Emails: Search for emails based on criteria (all, unread, read, flagged)
  • Get Email Attachments: Download attachments from a specific email

Connect with IMAP:

INFO

You need valid IMAP server credentials to establish a connection. For Gmail, Outlook, and other major providers, you may need to enable IMAP access and create an app-specific password.

  1. Go to Workflow Automation and navigate to Apps. Click the + Add Connection button. In the popup, select IMAP from the list.

  2. Fill in the connection fields: IMAP_01.jpg

  3. Fill in the Screen Name field with a descriptive name for your connection (e.g., "My Gmail IMAP").

  4. Fill in the IMAP Host field with your mail server's IMAP hostname:

    • Gmail: imap.gmail.com
    • Outlook/Office 365: outlook.office365.com
    • Yahoo: imap.mail.yahoo.com
    • Custom server: Your provider's IMAP hostname
  5. Fill in the Email/Username field with your email address or username.

  6. Fill in the Password field with your password or app-specific password.

    TIP

    For Gmail and Outlook, you should create an app-specific password rather than using your main account password. This is more secure and required if you have 2-factor authentication enabled.

  7. Select whether to Use TLS (recommended: Yes for secure connections).

  8. Fill in the IMAP Port field:

    • Port 993 for TLS/SSL connections (recommended)
    • Port 143 for non-TLS connections
  9. Click the Submit button to test and establish the connection.

  10. Your IMAP connection is now established. Start using your new IMAP connection with Workflow Automation.

Common Email Provider Settings

Gmail

  • IMAP Host: imap.gmail.com
  • Port: 993
  • Use TLS: Yes
  • Note: Enable IMAP in Gmail settings and use an app password

Outlook / Office 365

  • IMAP Host: outlook.office365.com
  • Port: 993
  • Use TLS: Yes
  • Note: Ensure IMAP is enabled in your account settings

Yahoo Mail

  • IMAP Host: imap.mail.yahoo.com
  • Port: 993
  • Use TLS: Yes
  • Note: Generate an app password

Using IMAP Triggers

New Email Trigger

The New Email trigger monitors a mailbox for new unread emails and triggers your flow when they arrive.

Configuration:

  • Mailbox: Select which folder to monitor (default: INBOX)
  • Mark as Read: Choose whether to automatically mark emails as read after processing

Output Data:

  • emails: Array of new email objects
  • count: Number of new emails
  • Each email includes: uid, messageId, from, fromName, to, cc, subject, date, textBody, htmlBody, hasAttachments, attachments

TIP

The trigger checks for new emails every 15 minutes. All new unread emails found are processed together in a single batch.

New Email Matching Criteria Trigger

The New Email Matching Criteria trigger allows you to filter emails based on specific conditions before triggering your flow.

Configuration:

  • Mailbox: Select which folder to monitor
  • From Filter: Filter by sender email address (case-insensitive, partial match)
  • Subject Filter: Filter by subject line (case-insensitive, partial match)
  • Body Filter: Filter by email body content (case-insensitive, partial match)
  • Has Attachments: Filter by attachment presence (Any/Yes/No)
  • Mark as Read: Choose whether to mark matching emails as read

Example Use Cases:

  • Monitor for emails from a specific customer: Set From Filter to customer@example.com
  • Watch for order confirmations: Set Subject Filter to order confirmation
  • Process emails with invoices: Set Has Attachments to Yes and Subject Filter to invoice

Using IMAP Actions

Read Email Action

Retrieve the full content of a specific email by its UID (Unique Identifier).

Parameters:

  • Mailbox: The folder containing the email (e.g., INBOX, Sent)
  • Email UID: The unique identifier of the email to read

Output: Complete email data including subject, body, sender, recipients, and attachments

TIP

You can get the UID from trigger output data or from the Search Emails action.

Mark as Read / Mark as Unread Actions

Change the read status of one or more emails.

Parameters:

  • Mailbox: The folder containing the email(s)
  • Email UID(s): Single UID or comma-separated list (e.g., 123,456,789)

Example: Mark multiple emails as read: {{trigger.emails[0].uid}},{{trigger.emails[1].uid}}

Delete Email Action

Permanently delete one or more emails from the server.

Parameters:

  • Mailbox: The folder containing the email(s)
  • Email UID(s): Single UID or comma-separated list

WARNING

This action permanently deletes emails. They cannot be recovered after deletion.

Move Email Action

Move emails from one folder to another.

Parameters:

  • Source Mailbox: The folder containing the email(s)
  • Destination Mailbox: The folder to move email(s) to
  • Email UID(s): Single UID or comma-separated list

Example Use Cases:

  • Archive processed emails: Move from INBOX to Archive
  • Organize by category: Move to custom folders based on content
  • Clean up inbox: Move old emails to specific folders

Search Emails Action

Search for emails in a mailbox based on various criteria.

Parameters:

  • Mailbox: The folder to search in
  • Search Criteria:
    • All emails
    • Unread emails
    • Read emails
    • Flagged emails
    • Unflagged emails
  • From Filter: Optional filter by sender (case-insensitive)
  • Subject Filter: Optional filter by subject (case-insensitive)
  • Max Results: Maximum number of emails to return (default: 50)

Output: Array of matching emails with full details

Example Use Cases:

  • Find all unread emails from a specific sender
  • Search for emails with specific keywords in the subject
  • Get the latest 10 emails from inbox

Get Email Attachments Action

Download attachments from a specific email.

Parameters:

  • Mailbox: The folder containing the email
  • Email UID: The unique identifier of the email

Output: Array of attachments with:

  • filename: Name of the attachment
  • contentType: MIME type (e.g., application/pdf, image/jpeg)
  • size: File size in bytes
  • content: Base64-encoded file content
  • contentId: Content ID (for inline images)

TIP

The attachment content is base64-encoded. You can use it directly with other actions that accept base64 data, or decode it if needed.

Example Workflows

Auto-Reply to Customer Emails

Trigger: New Email Matching Criteria

  • From Filter: @customer-domain.com

Actions:

  1. Read Email (get full content)
  2. SMTP: Send Email (auto-reply)
  3. Mark Email as Read

Process Invoice Attachments

Trigger: New Email Matching Criteria

  • Subject Filter: invoice
  • Has Attachments: Yes

Actions:

  1. Get Email Attachments
  2. Save attachments to cloud storage (Dropbox/Google Drive)
  3. Move Email to "Processed Invoices" folder
  4. Send notification to accounting team

Email Backup System

Trigger: New Email

Actions:

  1. Read Email (get full content)
  2. Save email data to database or spreadsheet
  3. Get Email Attachments (if any)
  4. Save attachments to backup storage
  5. Mark Email as Read

Smart Email Filtering

Trigger: New Email

Actions:

  1. Read Email
  2. Filter: Check if from important sender
  3. If yes: Move to "Priority" folder
  4. If no: Move to "Archive" folder

Troubleshooting

Connection Issues

Problem: Cannot connect to IMAP server

Solutions:

  • Verify IMAP host address is correct
  • Check that IMAP is enabled in your email account settings
  • Ensure you're using the correct port (993 for TLS, 143 for non-TLS)
  • For Gmail/Outlook: Use an app-specific password, not your main password
  • Check firewall settings allow IMAP connections

Authentication Failures

Problem: Invalid credentials error

Solutions:

  • Double-check username and password
  • For Gmail: Enable "Less secure app access" or use app password
  • For Outlook: Ensure IMAP is enabled in account settings
  • Try generating a new app-specific password

No Emails Found

Problem: Trigger doesn't detect new emails

Solutions:

  • Verify emails are actually unread in the mailbox
  • Check you're monitoring the correct mailbox folder
  • Ensure the polling interval has elapsed (15 minutes)
  • Test with the Search Emails action to verify connection works

UID Not Found

Problem: "Email with UID not found" error

Solutions:

  • Verify the UID is correct and the email still exists
  • Check you're looking in the correct mailbox
  • UIDs can change if emails are deleted or moved
  • Use Search Emails to get current UIDs

Best Practices

  1. Use App-Specific Passwords: For Gmail, Outlook, and other major providers, always use app-specific passwords for better security

  2. Monitor Specific Folders: Instead of monitoring all folders, focus on specific ones (INBOX, specific labels) to reduce processing

  3. Use Filtered Triggers: Use "New Email Matching Criteria" instead of "New Email" when you only need specific emails

  4. Handle UIDs Carefully: Email UIDs are unique within a mailbox but can change if emails are deleted. Always verify UIDs before operations

  5. Batch Operations: When processing multiple emails, use comma-separated UIDs in actions rather than multiple individual actions

  6. Mark as Read Strategically: Consider whether to mark emails as read automatically or manually control this based on processing success

  7. Archive Processed Emails: Move processed emails to archive folders to keep inbox clean and avoid reprocessing

  8. Test with Small Batches: When setting up new workflows, test with a few emails first before processing large volumes

  9. Handle Attachments Efficiently: Only download attachments when needed, as they can be large and consume resources

  10. Error Handling: Always include error handling in your flows, especially for email operations that might fail if emails are deleted or moved

Security Considerations

  • Credentials: IMAP passwords are stored encrypted in Workflow Automation
  • TLS/SSL: Always use TLS (port 993) for encrypted connections
  • App Passwords: Use app-specific passwords instead of main account passwords
  • Access Control: Limit IMAP connection access to necessary team members only
  • Regular Audits: Periodically review and rotate app-specific passwords
  • Sensitive Data: Be cautious when processing emails containing sensitive information

Rate Limits and Performance

  • Polling Interval: Triggers check for new emails every 15 minutes
  • Batch Size: Actions process up to 50 emails per batch for optimal performance
  • Connection Pooling: Each action creates a new IMAP connection and closes it after completion
  • Timeout: IMAP operations have a 30-second timeout
  • Concurrent Operations: Multiple flows can use the same IMAP connection simultaneously

TIP

For high-volume email processing, consider using multiple flows with different filters to distribute the load.