We Use Cookies

We use cookies to ensure that we give you the best experience on our website. If you continue to use this site we will assume that you are happy with this.

See our cookie policy.

Automation Action: For Each

Create a loop on various properties and execute Actions inside the loop.

Built-In Action

Allows you to create a loop based on the following:

  • Message Recipients (All, To, CC or BCC)
  • Message Attachments (Regular Attachments, Inline Attachments only or both)
  • Message Keywords
  • Message Headers
  • Extracted Fields
  • List values contained in a List (See: List Operation)
  • Lines contained in any variable
  • Comma Separated Values contained in any variable
  • Email addresses, URL's and Tokens contained in any variable
  • Data Reader Rows (See: Open Database Reader)
  • Json Member in
  • Variable Value

Inside the loop you can assign the values of the current loop item and current iteration count to variables. You can then use these values in actions within the loop.

For example, when looping on Recipients you can assign the Email Address & Name of the current recipient in the loop to variables by selecting from the Assign To drop downs.

When looping on Lines the Lines In will be split into lines (based on carriage returns and/or line feeds). Each non-blank line will then assigned to the loop value.

When looping on Comma Separated Values In, the In value will be split on commas. Quoted values will be handled. For example, if Comma Separated Values In contained:

1997,Ford,E350,"Super, luxurious truck"

.. then the loop would be executed 4 times with values:

  1. 1997
  2. Ford
  3. E350
  4. Super, luxurious truck

When looping on Json Member In the In value can be assigned any Json text. The loop will execute for each member. The Start At Path can be optionally set to a Json path (using dot notation). You can assign each member Name and Value to variables. See: Looping Through Json Member Values Using For..Each

When looping on Tokens the Tokens In value will be split into words and tokens.

When looping on Keywords the incoming message body will be split into unique words (excluding common words).

When looping on a Variable Value - this assumes the variable is numeric. The loop executes n times - where n is the variable value.

You then place actions to execute inside the For Each - Next Loop block.

Exit Loop

You can exit a loop using the Exit Loop action. This can be placed in an If block if you need to exit a loop based on a condition. Processing will continue with the action following the Next Loop action.

Continue Loop

The Continue Loop action moves processing to the Next Loop action. The loop will continue with the next iteration of the loop - or exit the loop if there are no more iterations. You can place the Continue Loop action in an If block if you need to move to the next iteration based on a condition.