- 16 Jul 2020
- 2 Minutes to read
Setting Up a Flow to Handle Email Events (IMAP)
- Updated on 16 Jul 2020
- 2 Minutes to read
An email event is a change in state on an email server, such as when the server receives or relays an email. The system can be configured to handle email events for a Post Office Protocol (POP3) server or an Internet Message Access Protocol (IMAP) server.
A POP3 server requires that clients download emails from the server to access them. An IMAP server allows a client to access emails directly on the server.
During the setup process, configure the mail server name, and the user name and password of the account with events to handle.
To set up a flow to handle email events, navigate to the folder System > Jobs and Events > Events, then use the dialog to set up the flow. Once the set up is complete, continue configuring the flow in the Flow Designer so that the event information can be displayed.
In the example, the Event Setup dialog is used to set up a flow to handle email events.
To begin, navigate to the folder System > Jobs and Events > Scheduled Jobs and click the New Scheduled Flow button.
In the New Scheduled Flow panel, name the job, then click the Create button next to the 'Scheduled Flow' box.
Begin by naming the Flow, then select the Scheduled Flow option under Flow Setup > Flow Usage. Click Create to create the Flow.
Begin creating the Flow by searching for and adding a Get Headers (Communication/IMAP) step to the end path of the Start step.
Next, select the Get Headers step and navigate to the Properties tab. Under Inputs, constant map the desired number of emails header data for the Flow to check under Count.
Then, Constant map the email server's info including the Username and Password for the email account being checked, and the Server Name and Port number if required.
After configuring the Get Headers step, search for an attach a ForEach step to the 'Received' path. From the ForEach step's Properties tab, Select From Flow map Headers to the Collection input. This will automatically adjust the Data type to EmailHeader which will allow the ForEach step to pass on the 'EmailHeader' data through the Flow.
Next, attach the 'Done' path to the End step, and then attach a Get Email (Communication/IMAP); configure this step's server settings the same way as the Get Headers step by mapping the same Password, Username, Server, and Port number. Then, 'Select From Flow' Headers.All UniqueId.First under the Unique Id input. Attach the 'Not Found' path to the End step, and then attach the 'Found' path to either the end Step, or any desired Email processing flows as an Async flow.
Debug the flow to ensure that it is functioning as intended, then, 'Save' and 'Close'.
From the New Scheduled Flow panel, scroll down to Schedule Configuration and select Time Span Schedule from the Calendar drop-down.
Next, scroll down to the Calendar Information and configure the TimeSpan. To configure this setting to run hourly, replace the number values in the boxes for Seconds, Minutes, and Days with a 0, and a 1 for Hours.
When completed and properly configured, the Flow will check for any new emails on an hourly schedule, and then send those emails through an asynchronous Sub Flow that processes the received Email data.