Email Sync
Audience:
Low-code Engineers,System/Security AdministratorsSkill Prerequisites:
Actions,Tokens,Connectors,Automation
The Email Sync add-on lets your applications process incoming email. It adds IMAP and POP3 connector types for mailboxes, and IMAP and POP Mail triggers for Automation jobs. The job runs its actions once for each new email, with the sender, subject, body and attachments in tokens. The add-on also adds actions to manage and test the mailbox connectors.
This add-on is the DnnSharp.EmailSync package. It's installed separately and needs the EMSYNC feature in your license. If it isn't licensed, the actions fail with a "not licensed" error and the IMAP trigger doesn't start listening. If you don't see the IMAP and POP3 connector types, or the Mail triggers in Automation, the add-on isn't installed.
What it adds
| Item | What it does | Use it to |
|---|---|---|
| IMAP trigger | Listens to one or more mailboxes and runs the job for each new email. | Process incoming email, such as orders, support requests or replies. This is the recommended trigger. |
| POP Mail (Obsolete) trigger | Checks one mailbox at a set interval and runs the job for each new email. | Keep existing jobs running. For new jobs, use IMAP. |
| IMAP and POP3 connector types | Store a mailbox's server, SSL setting, username, password and custom data. | Create mailbox connectors on the Connectors page. |
| Add Imap Connector | Adds an IMAP connector to a group. | Let users connect a mailbox from a form. In 1.28 it fails in apps, see the action page. |
| Update Imap Connector | Replaces all the details of an IMAP connector. | Save a new mailbox password. In 1.28 it fails in apps, use Update Connector. |
| Test IMAP Connector | Signs in to the mail server with one IMAP connector, or with every connector in a group. | Check mailbox details before the IMAP trigger uses them. |
| Add POP3 Connector | Adds a POP3 connector to a group. | Add a mailbox for an existing POP Mail job. |
| Update POP3 Connector | Replaces all the details of a POP3 connector. | Change a mailbox used by a POP Mail job. |
Mailbox connectors
Both connector types have the same settings:
| Setting | Description |
|---|---|
| Hostname (IMAP) or POP3 Server (POP3) | The mail server, for example imap.example.com. To use another port, add it after a colon, for example imap.example.com:1993. |
| Use SSL | Whether to connect with SSL/TLS. Without a port in the hostname, IMAP uses port 993 with SSL and 143 without it, and POP3 uses 995 and 110. |
| Username | The username or email address used to sign in. |
| Password | The password used to sign in. It's stored encrypted. |
| Custom Data | Extra name/value pairs. The IMAP trigger turns each one into a [CredentialData:<Key>] token, for example to tell which customer a mailbox belongs to. |
The triggers sign in with the username and password only. They don't use OAuth, so they can't connect to mail services that only allow OAuth sign-in. The IMAP trigger and Test IMAP Connector reject a connector with an empty Hostname, Use SSL, Username or Password.
IMAP trigger
Add the IMAP trigger from the Mail group to an Automation job. When the job is enabled, the trigger connects to each mailbox and keeps the connection open. It uses IMAP IDLE when the server supports it, so new email is processed soon after it arrives. On the first connection, it also processes the existing email that matches the trigger's settings.
The trigger opens the folder read-only. It doesn't delete, move or mark email.
Settings
| Setting | Description |
|---|---|
| Connector | The IMAP connectors to listen to. Pick one or more connectors, or a group. The trigger opens one connection for each connector, so keep it to about 20. |
| Start Date | Only email dated after this date is processed. Changing it on an active trigger resets where the trigger continues from, which can cause duplicates or missed email. |
| Ignore errors | When checked, an email that fails while its tokens are created or its attachments are saved is skipped, and the trigger continues with the next one. Errors in the job's actions never stop the trigger. |
| Folder to watch | Inbox (default) or All. All needs a server that supports the IMAP special-use folders. Otherwise the trigger watches the Inbox. |
| Make this go through all existing mail at first run | Processes all email in the folder, ignoring Start Date. It's turned off again after the next run. |
| Trigger only for new e-mails | Ignores Start Date and only processes email that arrives after the trigger first connects to a mailbox. Use it when connectors are added to the group later, for example by users. |
| Compact body text | Removes empty lines and extra spaces from [Mail:BodyText]. |
| Save Attachments | Saves each email's attachments to a portal folder before the job runs. |
| Attachments save directory | The folder for saved attachments. Supports tokens. When it's empty, the portal's Temp folder is used. |
| Handle duplicates | What to do when a file with the same name is already in the folder: Overwrite, Pattern Rename, Windows Rename or Date Rename. |
| Rename Pattern | The text added to the end of the file name when Pattern Rename is selected. Supports tokens. |
| Filter E-mail by subject, recipient, sender, Cc, Bcc or body | Only process email whose field matches. Without Use Regex, the value must match the whole subject, the whole body or one whole address exactly. With Use Regex, the value is a regular expression that must match. Filters support tokens. |
| Filter E-mail by attachments | Has attachments or Doesn't have attachments. |
| Custom Headers Filters | Header names and values. Only email that has the header, with exactly that value, is processed. |
| Select additional mail headers | Header names and token names. When an email has the header, its value goes into a token with the name you give, for example X-Priority → MailPriority gives [MailPriority]. |
Tokens
| Token | Description |
|---|---|
[Mail:From] and [Mail:FromName] | The sender's address and name. |
[Mail:To] and [Mail:ToNames] | The recipients' addresses and names, separated by commas. |
[Mail:Cc] and [Mail:CcNames] | The Cc addresses and names, separated by commas. |
[Mail:Bcc] and [Mail:BccNames] | The Bcc addresses and names, separated by commas. |
[Mail:Subject] | The subject. |
[Mail:DateSent] | The date the email was sent. |
[Mail:Body] | The HTML body if there is one, otherwise the text body. |
[Mail:BodyText] | The body as plain text. If the email only has an HTML body, it's converted to text. |
[Mail:BodyHTML] | The HTML body, if there is one. |
[Mail:HasAttachments] | True if the email has attachments. |
[Mail:AttachmentsNameList] | The attachment file names, separated by commas. |
[Mail:AttachmentsListJson] | The attachment file names as a JSON array. |
[Mail:UploadedAttachmentsInfoJson] | With Save Attachments, a JSON array with the FileId, FileName and RenamedFileName of each saved file. |
[Mail:RenamedAttachmentsNameListJson] | With Save Attachments, the saved file names as a JSON array. |
[Mail:DisallowedAttachmentsJson] | With Save Attachments, the attachments that weren't saved because their file extension isn't allowed in the host settings. |
[CredentialData:Hostname], [CredentialData:Username] and [CredentialData:UseSSL] | The settings of the connector the email came from. The password isn't available. |
[CredentialData:<Key>] | Each custom data value of the connector. |
To work with the attachments list, use Create List from JSON or Parse JSON into Tokens.
Errors and reconnecting
- Errors are saved in the job's history.
- If the connection drops, the trigger waits and reconnects, with a longer wait after each failure. When the wait passes 10 minutes, it stops and saves The job needs to be manually restarted after the error is fixed. Fix the problem, then restart the job.
- When you change a connector, for example its password, the trigger reconnects with the new details. When you delete a connector, the trigger stops listening to it.
POP Mail trigger (obsolete)
The POP Mail (Obsolete) trigger connects to one POP3 mailbox at the Check Interval you set, for example every minute. It processes the email received after its start date, then saves the date of the newest email as the new Start Date.
Its settings are like the IMAP trigger's, with these differences:
- It takes a single connector, and has Check Interval instead of Folder to watch, Ignore errors and Trigger only for new e-mails.
- Attachments save directory is required.
- Make this go through all existing mail at first run isn't turned off after a run, so every check processes all email in the mailbox again. Turn it off after the first run.
- Filters without Use Regex match when the field contains the value, instead of matching it exactly.
[Mail:To],[Mail:Cc]and[Mail:Bcc]contain names and addresses, such asJane Doe <jane@example.com>. There are no...Namesor[CredentialData:...]tokens.
For new jobs, use the IMAP trigger.
For sending email, see Email and Email OAuth. For the generic connector actions, see Connectors.
Revised 10/02/2026