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.
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.).
|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.
A logical operator always applies to the condition or group of conditions that is directly above on the conditions' list.
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:
- 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@example.com), who belongs to the Developers group, sends a message to John (firstname.lastname@example.org) from Marketing, this message will trigger the email rule.
- Or when a message is sent inside the organization (C). For example, the rule will be triggered if Claire (email@example.com), who belongs to the Management group, sends a message to Nicole (firstname.lastname@example.org) from the Technical Support group.
|Fig. 2. Example 1: conditions bound with logical operators (without groups).|
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 () button (Fig. 3.). You can remove the grouping brackets from selected conditions via the Ungroup () button.
|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.
|Fig. 4. Nested groups of conditions (this example is explained here).|
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.
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:
- 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@example.com), who belongs to the Developers group, sends a message to John (firstname.lastname@example.org) from Marketing, his message will trigger the email rule.
- 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@example.com) from Management sends a message to Nicole (firstname.lastname@example.org) from the Technical Support.
|Fig. 5. Example 2: conditions bound with logical operators (with groups).|
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.).
|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.).
|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)
(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)
(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.
|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:
- external email addresses if the subject of a message contains the phrase Offer or Newsletter;
- employees (internal email addresses) if the subject contains the phrase Promo,
if these messages contain at least one attachment.
|Fig. 9. Adding additional grouping brackets to conditions.|
Sender - this article describes how to configure the Sender condition.