How to group conditions

In CodeTwo Exchange Rules Pro, you can define multiple conditions for your email rule and create logical And/Or relationships between them. By skillfully using conditions and groupings, you have practically unlimited possibilities of defining conditions for rules. This article will help you understand how to create logical connections between conditions and how to group them.

And/Or relationships

Conditions can be connected by two types of logical operators:

  • And – if you use this operator to bind two or more conditions together, this creates a logical conjunction between these conditions. This means that an email message needs to fulfill all of these conditions to trigger the corresponding email rule.
  • Or – this operator creates a logical disjunction between conditions. In other words, if you connect two or more conditions via this operator, the corresponding rule will be triggered for messages that fulfill at least one of these conditions.

You can use both operators to create the connections between conditions. To help you understand how multiple conditions will be executed, the logical relationship between them is shown at the bottom of the RULE PROPERTIES pane (Fig. 1.).

Binding conditions together via logical operators.
Fig. 1. Binding conditions together via logical operators.

The way you use And/Or relationships is crucially important because it controls when rules (and the resulting actions) are executed.

Important

A logical operator always applies to the condition or group of conditions that is directly above on the conditions' list.

Example #1

In Fig. 2. three conditions (A, B and C) are connected in the following way: A and B or C. Here, the rule is applied only in the following two scenarios:

  1. When the sender's email address matches the @company.com domain and the recipient belongs to the Marketing group (A and B). For example, if Mark ([email protected]), who belongs to the Developers group, sends a message to John ([email protected]) from Marketing, this message will trigger the email rule.
  2. Or when a message is sent inside the organization (C). For example, the rule will be triggered if Claire ([email protected]), who belongs to the Management group, sends a message to Nicole ([email protected]) from the Technical Support group.

Example 1: conditions bound with logical operators (without groups).
Fig. 2. Example 1: conditions bound with logical operators (without groups).

Creating groups and nests

Besides defining conditions, the administrator of the program can also group multiple conditions and define logical relationships between these groups in the same way as for individual conditions. Thanks to this capability, any clause of grouped conditions can work as a separate unit from the other conditions defined within an email rule.

To group conditions, select the ones you want to group by holding the Shift or Ctrl key, and click the Group (ER Pro 2.x - conditions grouping button) button (Fig. 3.). You can remove the grouping brackets from selected conditions via the Ungroup (ER Pro 2.x - remove conditions grouping icon) button.

Grouping conditions.
Fig. 3. Grouping conditions.

You can use the grouping brackets to nest groups of conditions within one another (Fig. 4.). To help you visualize the final effect, the program shows the resulting logical relation at the bottom of the pane.

Nested groups of conditions.
Fig. 4. Nested groups of conditions.

A logical operator always applies to the group of conditions that is directly above on the conditions' list. See the example below and compare it with Example #1 to understand you can modify conditions by using groups.

Example #2

In Fig. 5. three conditions (A, B and C) are connected in the following way: A and (B or C). Here, the rule is applied only in these two cases:

  1. The sender's email address matches the @company.com domain and the recipient belongs to the Marketing group (A and B). For example, if Mark ([email protected]), who belongs to the Developers group, sends a message to John ([email protected]) from Marketing, his message will trigger the email rule.
  2. The sender's email address matches the @company.com domain and the message is sent inside the organization (A and C). For example, the corresponding rule will be triggered if Claire ([email protected]) from Management sends a message to Nicole ([email protected]) from the Technical Support.

ER Pro 2.x - Conditions grouped.
Fig. 5. Example 2: conditions bound with logical operators (with groups).

Examples of usage

To get a better understanding of the grouping feature, see the examples below.

Let us assume that we want to add a promotional signature to messages sent from the Marketing department to all external email addresses. This can be achieved by adding two conditions and binding them via the And operator (Fig. 6.).

Two sample conditions.
Fig. 6. Two sample conditions.

To make the conditions more complex, we decide that the signature should be added only if the previously defined conditions (A & B in Fig. 6.) are true, and when the subject of a message contains the phrase Offer or Newsletter. This requires additional two conditions (C & D) connected via the Or operator (Fig. 7.).

Adding more conditions.
Fig. 7. Adding more conditions.

However, the outcome of such a composition is not exactly what we wanted. According to the order of executing logical conditions, our expression will be true if the phrase Newsletter is found in the subject (condition D) or, independently, if the other three conditions (A and B and C) are fulfilled. To better understand this, let's use brackets to show how conditions from Fig. 7. are executed:

(Sender belongs to the Marketing group And Recipient is external And the message subject contains the phrase Offer)
Or
(the subject of a message contains the phrase Newsletter)

The outcome we wanted to achieve was different:

(Sender belongs to the Marketing group And the Recipient is external)
And
(the message subject contains the phrase Offer Or it contains the phrase Newsletter)

We can achieve this result by grouping the conditions, as shown in Fig. 8.

Grouping conditions.
Fig. 8. Grouping conditions.

By nesting the conditions within one another, we can make our conditions even more complex. After the modifications shown in Fig. 9., our promotional signature will be added to messages sent by the Marketing department to:

  1. external email addresses if the subject of a message contains the phrase Offer or Newsletter;
  2. employees (internal email addresses) if the subject contains the phrase Promo,

if these messages contain at least one attachment.

Adding additional grouping brackets to conditions.
Fig. 9. Adding additional grouping brackets to conditions.

See next

Sender - this article describes how to configure the Sender condition.

In this article

Was this information useful?