Downloading Email From a Mail Server [POP]Last Updated: 07/21/2016 Introduced in Verision: 2.0 |
Using the Get Email component, a flow can retrieve messages from a mail server. The flow can display the messages in a form or use them in other ways.
The Get Email component is also available for use with an IMAP mail server.
To enable a flow to download emails from a POP mail server, in the Toolbox panel, in the category Communication > POP, drag a Get Email component to the workspace and configure its properties in the Properties panel.
Example
Our example flow will retrieve one message from our Gmail account and display its body text and headers in a form.
A form to display the email – Form 1 – has already been created for this example.
We’ll begin by navigating to a project folder and clicking the Create Flow button.
On the New Flow pop up give the flow a name and click OK to open it in the Flow Designer.
The first step that we will add to our flow will retrieve a message header.
To retrieve message headers, Get Headers 1 must be configured with the appropriate settings for the Gmail server. Most of the following settings are specific to the POP protocol. To download messages from a mail server via IMAP, refer to the article on Downloading Email From a Mail Server [IMAP].
Configure Get Headers 1’s settings in the Properties panel, in the Inputs section. Because we only want to get one message, in the Count section, we will enter “1” in the Value field.
In the Port section, in the Value field, we’ll enter “995”. We will also want to ensure that our authentication details are kept secure. In the Secure Connection section, we’ll select the Value checkbox.
Once our flow has retrieved a message header, the Get Email component uses the header to retrieve the full message.
Just as we configured the step Get Headers 1, we will also have to configure Get Email 1 with similar settings.
We will configure Get Email 1’s settings in the Properties panel, in the Inputs section.
In the Port section, in the Value field, we’ll enter “995”.
The Get Email step also uses a Unique ID. This field works on the assumption that previous steps may output more than one message header, from which we may only want to get a certain category of message.
Once our flow has retrieved a message, it needs to display that message in a form, which we’ve already designed.
In the Toolbox panel, under the category Forms [Interaction] > [Current Folder], drag a Form 1 component to the workspace.
Next, we must map the outcomes of our flow steps.
Our last unfulfilled requirement is to make our form display the message details, so we will map the inputs for [Form] Form 1 in the Properties panel, under the section Inputs > Email. In the Mapping type drop-down list, we’ll select Build Array, which will allow us to build a list of items for display in our form.
In the Item 0 section, we will select Select Value in the Mapping type drop-down list, and click the Path selector.
We’ll select GetEmail1_Message then click OK.
This completes our flow. It is now ready to save and test in the debugger.
Note that in Decisions version 3.5 and above, you’ll need to click on Test Flow to access the Debugger.
Because our flow interacts with external systems, we can see the lag time between our flow and Gmail’s servers reflected in real-time in our debugger’s events and on the Diagram tab. This view is by no means a perfect indicator of network health, but if we were to see a significant lag between steps, it might be an indicator of a problem worth exploring. The lag-time we see debugging in this example flow is perfectly normal.
Our flow works. As required, we are presented with a form that displays the details of a single message downloaded from our Gmail account.