RPA Flow to read the list of emails and copy the content into a .txt file

Create an RPA flow to read the list of mails in your mailbox and copy the contents in a .txt file.

Pre-requisites for flow creation

To create this RPA flow, you must ensure to:

  • Create a folder to store the .txt file where the mail body is copied. For example, “C:\RPA”
  • Create a .txt file within this folder, For example, “C:\RPA\rpa.txt”

Creating a flow

This chapter lists the steps required to create an RPA flow for reading a list of emails and copying the content to a .txt file.

  1. Log on to the RPA Studio application. The home page is displayed.
  2. Click New Project. The New Project screen is displayed.
  3. Specify the basic information related to the new project.
  4. Click Create. The canvas to design the workflow is displayed with the Project menu open by default.
  5. Select the project file to display the Sequence window for creating an RPA flow.
  6. Click Activities to open the Activities panel.
  7. Add the Get Outlook Emails (Emails > Get Outlook Emails activity to the canvas.
  8. Specify this information in the Properties panel on the right side of the screen:
    Account
    Your mail address from which the bot must read the mails. For example, adam.smith@infor.com. You can also create a variable of ‘String’ type with a default value.
    MailFolder
    The name of the folder within the mail account. For example, test. You can also create a variable of ‘String’ type with a default value.
    Filter
    The properties based on which the e-mails must be filtered. For example, “[Subject] = test”. See Filters for more information.
    Mark as Read
    Select this check box if the email must be marked as Read in your email box.
    Only Unread E-mails
    Select this check box to open only those emails that were not read previously.
    Top Number of Emails
    The maximum number of emails to consider. For example, 2.
    Emails
    Create a variable System.Collections.Generic -> List <T>. Select Infor.Activities.Email.Mail for the T value.
  9. Add the For Each (Workflow > For Each) activity to the canvas.
  10. Specify this information in the Properties panel on the right side of the screen:
    Type Arguments
    Select Mail (Infor.Activities.Email.Mail)
    Values
    Create a variable. For example, emaillist. Items in the list of the mails stored in this variable are considered.
  11. Add the Sequence (Workflow > Sequence) activity to specify the flow for reading each mail body and writing to the file.
  12. Add Assign (Primitives > Assign) in the Sequence activity to assign the mail body to a variable of String type.
  13. Specify this information in the Properties panel on the right side of the screen:
    To
    Create a variable of String type. For example, body. The text of an email is stored in this variable.
    Value
    Specify a VB expression for reading the mail body and transforming the text to string data type. For example, item.body.tostring.
  14. Add the Append Line (System > Append Line) activity.
  15. Specify this information in the Properties panel on the right side of the screen:
    Line
    Create a variable to store the body of the email.
    Source Filepath
    Specify the location where the .txt file must be stored. For example, C:\RPA\rpa.txt. You can also create a variable of the String type with default values.
  16. Add the Download Outlook Attachment (Email > Download Outlook Attachment) activity to download attachments, if any.
  17. Specify this information in the Properties panel on the right side of the screen:
    Email
    Specify Item. Item is a single mail within the mail list.
    Path
    The location where the attachment must be stored.
    File Path
    Create a variable to store the list of paths(locations) where the attachments are downloaded.