For Each Email

This step opens an application in the Recorder View with a single message from the selected email folder. The message data is available in the table and tree views. This step works as a loop step that iterates over the messages in the email folder. Each iteration updates the contents of the views with data extracted for the next message. After all messages are iterated (or the Robot exits the loop with an exception or a Break step), the application automatically closes. It also closes if the Robot stops executing.

The Robot may use an iteration variable and Continue and Break steps to control the loop execution as the other loop steps.

For each message, the table lists the following properties as columns:

  • From: The sender in the format John Doe <j.doe@organization.com>.

  • Subject: The subject line of the message.

  • Received: The date when the message was received, in the format 2023-05-17T15:27:33+01:00 (ISO-8601).

  • Size: The size of the message in bytes.

  • Has attachment: Whether the message has one or more attachments.

  • Is read: Whether the message is marked as read.

  • Attachment count: The number of the attachments.

The For Each Email step belongs to the Loop and Applications categories.

Properties

Application Name

Provide a name for the application.

Assign different application names to applications in a Robot to avoid errors.

Protocol

Select the email protocol used to connect to the email server: Select from "imap", "pop3," and their secure variants "imaps," "imap+tls," and "pop3s." The option "imap+tls" is for email servers requiring opportunistic TLS.

Email Server

Specify the name or address of the email server.

Email Server Port (optional)

Specify a port number of the email server. If not provided, the standard port of the selected protocol is used.

Account Name and Password

Enter credentials to log in to the email server.

Path in Mailbox (optional)

The name of the folder to open on the email server. It may be in the form of a path for a nested folder, in which case the elements in the path must be separated with slashes. To open the folder where the incoming email is stored, do not provide any path or name.

Examples: Junk E-Mail, Subscriptions/Mailing lists.

Leave this field blank when using the POP3 or POP3S protocols, as POP3 does not support folders.

Retrieval Batch Size (optional)

This setting determines how many messages are retrieved from the mail server at once. It does not affect the loop, which still shows one message per iteration. You need to change the value of the setting only when the step execution causes errors. In this case, you can decrease the value if the Robot runs out of memory, or increase it if the mail server reports that too many requests are made. The default value is 100.

Iteration Variable (optional)

Specify a variable to store iteration data.

Component actions

The following component actions are provided.

Action

Description

Copy message

For IMAP and IMAPS protocols. Copies the selected message to the specified target folder. The availability of the action depends on whether the email server supports the copy operation.

Delete message

Removes an email message.

Get message content

Returns a string value containing the message and headers in RFC 822 format.

Open message as HTML

Opens an email as an HTML web page, using the Chromium built-in browser. Operates on a row in an opened email table.

Move message

For IMAP and IMAPS protocols. Moves the selected message to the specified target folder. The availability of the action depends on whether the email server supports the move operation.

Mark message as read

For IMAP and IMAPS protocols. Flags a message as read or unread.

Select the check box Is read to mark the message as read, or clear the check box to mark the message as unread.

Get attachment

Retrieves the attachment binary data and stores it in a variable. This action is useful when the attachment is large.

To retrieve the required data, configure the following properties.

  • Index: A zero-based index of the attachment to extract.

  • Attachment data: The binary variable that stores the resulting attachment data.

POP3 or POP3S protocol restrictions
  • No folder support.
  • Some POP3 servers do not reflect changes made through the POP3 connection on other interfaces. For example, when a Robot deletes a message from a Gmail account using the POP3 protocol, the web browser interface may continue to show that message. For the robot, the message is deleted.
  • The Delete Message step marks a message for deletion, but it stays on the server until the application is closed.
  • Most POP3 servers delete messages once they have been downloaded.
  • The "read" or "unread" flag cannot be set.