Setting Up a Flow to Handle Email Events (IMAP)
  • 26 Jan 2021
  • 2 Minutes to read
  • Dark
    Light

Setting Up a Flow to Handle Email Events (IMAP)

  • Dark
    Light

Article Summary

Overview

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. The following document demonstrates how to create an Email Handling Event in the System Folder.


Example

  1. Navigate to System > Jobs and Events > Scheduled Jobs.
  2. Select the NEW SCHEDULED FLOWbutton from the top Action bar. 
    1. Provide a Scheduled Job Name.
    2. Select PICK SCHEDULED FLOW, Flow, provide a Name, then click CREATE. 
  3. Attach a Get Headers step from the EMAIL > IMAP category under the Toolbox tab, to the Start step.
  4. Navigate to the Get Headers step's Properties tab and map the server's credentials to each respective INPUT
    The following example uses settings for a Gmail Server set up to work with IMAP. These INPUTS are Username, Password, Server (Name), and the Port number.

    For more information regarding these settings see Set Up IMAP for Gmail.
    1. Define a Count number and check the Unread Messages Only box. 
      Count is used to define how many pieces of Email data are retrieved by the Flow.

      Unread Messages Only ensures that the Flow retrieves unread messages. Leaving this unchecked will retrieve any message, regardless of "read" status.

  5. Attach a ForEach Step to the Received path of the Get Headers step, from the ITERATION category of the Toolbox tab.
  6. Navigate to the ForEach Step's Properties tab and Select From Flow map Headers to INPUTS > Collection.
    Mapping Headers to Collection will automatically adjust the Data type to EmailHeader which will allow the ForEach step to pass on the 'EmailHeader' data through the Flow.

  7. Attach the Done path to the End step, then attach a Get Email step from EMAIL > IMAP,  to the Next path. 
  8. Configure the Get Email step's INPUTS to match the Properties of the Server mapped into the Get Headers step. 
  9. Select From Flow map Headers.All UniqueId.First to Unique Id. 
    Mapping the First Headers output to the Unique Id, allows the Get Email step to retrieve the first cycled through message. 

  10. 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 Sub Flow.
    When using Asynchronous process logic via Sub Flow, map the Message Output to the Sub Flow's Inputs to properly send the Email through the Flow.

  11. Debug the Flow to ensure that it's working as intended. 
  12. Save the Flow, then close with X.
  13. From the New Scheduled Flow window, under Schedule Configuration > Calendar, select Time Span Schedule from the dropdown menu. 
  14. Scroll to Calendar Information and configure the TimeSpan by replacing the number values in each box for Seconds, Minutes, Hours, and Days
    Set the Flow to run every hour by inputting 0 Seconds, 0 Minutes, 1 Hour[s], and 0 Days. 

  15. SAVE the New Scheduled Flow.
    When completed and properly configured, the Flow will check for any new emails based on an hourly schedule, and then, if configured, will send those emails through an Asynchronous Sub Flow that processes the received Email data.

Was this article helpful?