activities
latest
false
Productivity Activities
Last updated Oct 23, 2024

For Each Email

UiPath.Mail.Activities.Business.ForEachEMailX

Executes one or more activities for each email or email invite in a specified Outlook folder or with a specified Gmail label. This activity must be added inside a Use Outlook 365, Use Gmail, or Use Desktop Outlook App activity.

Use this activity when you are working with multiple messages and you want to repeat one or more activities for each individual message:

  • For the Outlook desktop app, indicate a folder whose emails to iterate through, or iterate through the folder or the emails that are selected in Outlook when the project is executed.
  • For Outlook 365, indicate a folder whose emails to iterate through.
  • For Gmail, indicate a label whose emails to iterate through. You can select a custom label or one of the following default labels: Inbox, Sent, and Spam.

Add the activities to repeat inside For Each Email and, when you configure the activities, select CurrentMail from the Plus menu to indicate that you want to repeat the actions for each message in the iteration. For some activities, you must select a specific message field to use from each email: Subject, Body (message body in plain text), Body as HTML (message body formatted in HTML), Date (as text), Bcc, Cc, To, From (sender and recipient fields return a list of email addresses separated by semicolon), or Priority (High, Low, Normal).

To learn how to use this activity, see:

Configuring the Activity

In the Body of the Activity
  • For each - Enter the name by which to refer to the current email in the iteration. Using a name that describes the type of email makes it easier to identify and select the current email option when configuring activities added inside For Each Email. For example, for a selection of emails that contain invoices, you can enter Invoice. The default value is CurrentMail.
  • In emails from - Click Plus docs image on the right side of the field and then, from the menu, select the folder or label you want to use, or, when automating the Outlook desktop app, choose Selected Mails or Selected Folder to use the messages or the folder selected in Outlook when the project is executed. Alternatively, you can select Open in Advanced Editor and enter a VB expression.
  • Limit emails to first - Enter or select a limit for the maximum number of emails to process. Set a lower limit if you want to reduce processing times. The default value is 100 emails.
  • Unread mail - Select this option if you want to process only unread emails. This option is not selected by default.
  • Retrieve attachments - Select this option if you want to retrieve the attachments along with the emails.
  • With attachments only - Select this option if you want to process only emails that contain attachments. This option is not selected by default.
  • Include subfolders - Select this option if you want to expand the iteration to include all subfolders of the selected mail folder. This option is not selected by default.
  • Additional filters - Click this button to configure an advanced filter for the emails to process.

    In the Filter window:

    • From the first drop-down menu, select an email field to filter by: Bcc, Body, Cc, Date, From, To, Subject, or Categories.
    • From the second drop-down menu, select an operator to evaluate the email field:

      • For all fields with the exception of Date and Categories: contains, does not contain, ends with, starts with, equals, is empty, or is not empty.
      • For the Date field: older than, newer than, or equals the time period indicated in the third field.
      • For the Categories field: contains, does not contain.
    • Click Plus on the right side of the third field, and then use one of the options in the menu to indicate the value against which to evaluate the selected email field:

      • Data from the Project Notebook, a parent Excel file or email account. For example, indicate a field in the email that is selected in Outlook when the project is executed.
      • Use Saved Value - Use data that you previously saved for later use in the project.
      • Text - Enter text in the Text Builder.
      • Ask when run - Prompt for a value when the project is executed.
      • Paste from clipboard - Paste a value that you previously copied to the clipboard in the project.
      • Open in Advanced Editor - Enter a VB expression.
    • Click Add if you want to add other conditions, and select if All or Any of the conditions should be used to filter.

      Important:

      When used with the Use Outlook 365 activity on .NET 5 projects some filters are not supported.

      All filters applied to the Body, To, Cc, and Bcc fields are not supported. Refer to the table below for a more detailed list of unsupported filters.

Unsupported filters

Field

Filter

Subject

Not Contains

Subject

Ends With

Subject

Is Not Empty

Subject

Is Empty

From

Ends With

From

Equals

From

Is Not Empty

From

Is Empty

Properties Panel

Common

  • DisplayName - The name displayed for the activity in the Designer panel.

Misc

  • Private - If selected, the values of variables and arguments are no longer logged at Verbose level.

Options

  • See the options in the body of the activity.

    Note: When automating the Outlook desktop app, the activity only processes emails stored locally in the Outlook data file. For information on what to do if some of your emails are not processed, see Outlook Troubleshooting in the StudioX Guide.
  • Configuring the Activity

Was this page helpful?

Get The Help You Need
Learning RPA - Automation Courses
UiPath Community Forum
Uipath Logo White
Trust and Security
© 2005-2024 UiPath. All rights reserved.