If-else functionality

We do not offer support for the following functionality. If the functionality is not inserted into the source text correctly this can lead to display errors for the email recipients.


In the following example step 1. checks if the field SALUTATION contains any values to create the output of this condition which is “Dear Mr Smith”. If the field SALUTATION is empty “Dear Recipient” will be displayed instead.

Example 1

{IF[SALUTATION]}
Dear {SALUTATION} {LASTNAME}
{ELSE[SALUTATION]}
Dear Recipient
{ENDIF[SALUTATION]}


The following example explicitly checks if the recipient is male or female. Depending on this check certain products will be displayed.

Example 2

{IF[SALUTATION=="Herr"]}
Texts and offers for men
{ELSE[SALUTATION]}
Texts and offers for women
{ENDIF[SALUTATION]}


In the following example we check if the field “Salutation” contains a value. If this is the case we either display “Dear Mr.” or “Dear Ms.” plus the last name. If the salutation is empty the salutation will read “Dear all”.

Hint: This only works if under “Salutation” you only have the values “Mr.” for men and “Ms.” for women.

Example 3

{IF[SALUTATION]}
{SALUTATION_FORMAL} {LASTNAME},
{ELSE[SALUTATION]}
Dear all,
{ENDIF[SALUTATION]}


If two separate database fields need to be checked for content you will need a nested condition. In this scenario the query must include two separate fields (in this example SALUTATION and TITLE):

Example 4:

{IF[TITLE]}
{SALUTATION_FORMAL} {TITLE} {LASTNAME},
{ELSE[TITLE]}
{IF[SALUTATION]}
{SALUTATION_FORMAL} {LASTNAME}
{ELSE[SALUTATION]}
Dear all,
{ENDIF[SALUTATION]}
{ENDIF[TITLE]}


Example 5:

You can also create nested conditions. In the following example we will check if the salutation “Mr.” or “Mrs.” is available. If this is not the case the default salutation will be displayed.

{IF[SALUTATION=="Mr."]}Dear Mr. {LASTNAME},
{ELSEIF[SALUTATION=="Mrs."]}Dear Mrs. {LASTNAME},
{ELSE[SALUTATION]}Dear all,
{ENDIF[SALUTATION]}

Further checks can be added to a condition to verify that a name even exists before the salutation is checked:

{IF[LASTNAME]}
{IF[SALUTATION=="Mr."]}Dear Mr. {LASTNAME},
{ELSEIF[SALUTATION=="Mrs."]}Dear Mrs. {LASTNAME},
{ELSE[SALUTATION]}Dear all,
{ENDIF[SALUTATION]}
{ELSE[LASTNAME]}Dear all,
{ENDIF[LASTNAME]}


Important notes:

  1. Do not alter the code guidelines (names of variables can of course vary). Not following the default code exactly can lead to severe display issues with email campaigns, drafts and/or templates. The worst case scenario is a completely empty email being sent or an email being sent multiple times to the recipients.
  2. Variables within square brackets or curly brackets must be written with all caps!
  3. Don’t enter your own spaces into the if-condition.
  4. Check and test the code instructions in all their details and consider all contingencies!
  5. Making use of this functionality can have a negative effect on the sending performance.
  6. Please note that the fields used above (e.g. SALUTATION) are merely examples and that your fields might differ significantly. You will find the names of your fields in your data fields overview.

We explicitly want to mention that this is not an official CleverReach feature and that we cannot be made responsible for any problems that might occur if mailings, layouts, distributions, templates and others are impacted. CleverReach does not offer support for this functionality.