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: Sender in the format John Doe <j.doe@organization.com>

  • Subject: Subject line of the message.

  • Received: Date when the message was received, in the format 2021-12-13T15:27:33+01:00 (ISO-8601)

  • Size: 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.

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.

Copy message and Move message (for IMAP and IMAPS protocols)
The actions copy or move the selected message to the specified target folder. The availability of the actions depends on whether the email server supports the copy and move operations.
Mark message as read (for IMAP and IMAPs protocols)
This action 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 message content
This action returns a string value containing the message and headers in RFC 822 format.
Delete message
This action removes an email message.
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 aRrobot 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.