Overview

Sections

How to create an RPA flow using Outlook Email activities

Intermediate | 25 Minutes

RPA

Overview

You need to create a basic flow using some of the Outlook automation activities to read mail and store attachments.

We will build an RPA flow which first reads emails from an Outlook account. Then, for each email, the email text body will be written into a .txt file, including the attachments one by one.

📋 Requirements

Before you can start building the flow, you’ll need to install RPA Studio on your machine and set up a connection between the RPA Studio and RPA Management. Check the Infor RPA Studio User Guide for the steps on how to do so.

You may also need to create a few artifacts:

  • Create a folder to store the .txt file where the mail body will be read into, e.g., “C:\RPA”
  • Create a .txt file within this folder: “C:\RPA\rpa.txt”
  • You can also create a sub-folder inside your Outlook account named “Test” where you can send/save 2 mails with the subject "Test" containing attachments.

Tutorial

This tutorial explains how to create a basic flow in Infor RPA Studio to read email messages and download their associated attachments by using Infor’s automated email Outlook activities.

1

Open RPA Studio

Open RPA Studio on your machine. If you are not signed in already into the tenant, you will be asked to sign in before proceeding to the RPA flow designer screens.

2

Create a new project

On the Home page of RPA Studio, click Create New Project and specify the following properties in the pop-up window:

  • Name: OutlookMails
  • Project Location:
  • Description: Read Outlook Mails.
  • Language: VB (selected by default)

3

Add Get Outlook Email activitiy

Let’s first focus on reading the mails from the Outlook account. For that, we need to add the Get Outlook E-mails activity to the flow and specify the following properties:

  • Account – which is the email address from which the email is read. Specify the argument: mailaccount of type string with the default value of your email account.
  • Mail Folder – the exact email folder within the selected account. Specify the argument: mailfolder of type string with the default value of your email account.
  • Optional: Filter – use this property to filter the emails that should be read, e.g., “[Subject] = Test”.
  • Mark As Read – check this if you don’t want to read the same email again.
  • Only unread mails – check this checkbox to only read unread emails (explicit filter).
  • Top Number of emails – an integer value specifying how many emails should be read in one go, e.g., 2.
  • For the Output property Emails, create the variable emaillist which will store the list of emails of type List .

To find List data type, expand the Variable Type and select Browse for type. In the Type Name cell, type List and select List under the System.Collection.Generic domain. Then, under System.Collection.Generic.List, select Browse for type and in the new dialog window in the Type Name cell, type Mail and select Mail under Infor.Activities.Email.

4

Read Emails with For Each

Now, let’s start reading the emails one by one. For that, add a For each automation activity:

  • For the Type property, select Mail (which is the type of a single object from the emaillist variable).
  • For the Values property, define emaillist.

In the ForEach activity on the Design Canvas, you will see the following text: “For each item in emaillist” – the item signifies a single mail object in this list.

5

Add Sequence activity

Add a Sequence activity to specify the flow for reading each mail body and writing it to the file. A Sequence activity is required inside the ForEach activity to define the flow.

6

Add Assign activity

Within the Sequence, add the Assign activity to assign the mail body to a variable of type string. On the Properties panel:

  • For the To property, create a variable called body of type string to store the text of the mail body.
  • For the Value property, specify the VB expression: item.body.ToString().

7

Add Append Line activity

Next, add the Append Line activity, which will allow the RPA flow to write the mail body into a .txt file. To specify its properties:

  • For the Line property, input the variable storing the body of the mail, which in this case is body.
  • For the Source Filepath property, specify the path of the .txt file where the mail body will be written, e.g., “C://RPA/rpa.txt”. Alternatively, you can create a variable called filepath of type string with a default value.

8

Add Download Outlook Attachments activity

Additionally, if attachments were sent, add the Download Outlook Attachment activity. Specify the following input and output properties:

  • For the Email input property, specify Item as in the ForEach activity.
  • For the Path input property, create a variable called attachmentpath of type string with a default value of "C:\RPA".
  • For the File Paths output property, create a variable called attachmentfilepath of type List <String>.

To find List <String> data type, expand the Variable Type and select Browse for type. In the Type Name cell, type List and select List under the System.Collection.Generic domain. Then, under System.Collection.Generic.List, select String.

Now you can run this flow to see if everything works as expected. In case of any errors, check the Output panel to see where the error may have occurred.

Was this section helpful?

What made this section unhelpful for you?

On this page
  • How to create an RPA flow using Outlook Email activities
View as Markdown

Ask an AI

Open in ChatGPTOpen in Claude