Knowledge Base

How to automatically remove blank spaces from email signatures if Entra ID / AD data is missing

Problem:

Your email signature template contains a placeholder that is dynamically filled with a matching attribute value from Entra ID or Active Directory when an email is sent. If the attribute has no data, then an empty space is left in the signature where the placeholder should be. This article explains how to automatically remove such placeholders, along with the space they occupy.

Solution:

CodeTwo email signature management software includes a built-in feature called Remove if blank or Remove Text tag (RT tags). This feature is particularly useful in email signature templates that include Entra ID / Active Directory (AD) placeholders. By surrounding a placeholder with RT tags, the CodeTwo software will automatically remove it from a signature if that placeholder cannot be replaced with the corresponding data from Entra ID, AD or CodeTwo Attributes manager.

CodeTwo Attributes manager lets you or your users manage selected contact data used in email signatures without making any changes to the user directory. It also allows you to create custom attributes that open up new ways of using email signatures. Learn more

Remove Text tags can remove not only blank placeholders, but also accompanying elements, such as:

  • Preceding text (also known as a signaling phrase), such as Phone.
  • A preceding icon, for example Phone icon - purple.
  • Entire HTML elements, for example an entire table row or a linked icon, if the placeholder within the RT tags is empty.

Use the links below to learn more and see examples.

Conditional placeholders

CodeTwo software also features conditional placeholders that can be used as an alternative for RT tags. Instead of removing empty placeholders, conditional placeholders can be used to insert custom data into email signatures in case some Entra ID / AD attributes are missing, e.g. company’s generic phone number instead of sender’s personal phone number, an avatar instead of a user photo, a department name instead of a job name, and so on. Learn more about conditional placeholders used in:

How to use RT tags to automatically remove empty placeholders and accompanying phrases

  1. Open your CodeTwo software and edit the signature template that includes placeholders.
  2. In the template editor, find the placeholder and any accompanying text (e.g. Phone: {Phone}).
  3. Use the mouse to highlight (select) both the text and the placeholder.
  4. Click Remove if blank (in CodeTwo Email Signatures 365) or Remove Text tag (in CodeTwo email signature software for on-premises Exchange) on the editor’s ribbon (Fig. 1.). Repeat steps 2–4 for all applicable placeholders.

Adding RT tags to an email signature template in CodeTwo Email Signatures 365.
Fig. 1. Adding RT tags to an email signature template in CodeTwo Email Signatures 365.

  1. The selected content will be automatically wrapped with RT tags, as shown in Fig. 2.

The selected element has been surrounded by RT tags.
Fig. 2. The selected element has been surrounded by RT tags.

  1. Now, if the placeholder surrounded by RT tags has no corresponding value in Entra ID / AD for the message sender, CodeTwo will remove it automatically when the email is sent (Fig. 3.).

An empty placeholder removed along with its signaling phrase.
Fig. 3. An empty placeholder removed along with its signaling phrase.

If the content enclosed in RT tags occupies the entire line or row, there are two ways to make sure the signature will not contain any unwanted white space (empty lines):

  • (Recommended) Put the closing RT tag at the beginning of the next line (Fig. 4.).

The correct placement of RT tags removes the empty line.
Fig. 4. The correct placement of RT tags removes the empty line.

  • (Alternative) Set the paragraph margins size to 0.1px. This way, empty lines take up virtually no space in the signature. To do that, select a signature line, go to the Formatting tab and change the top and bottom margin values (Fig. 5.).

Changing margin values for specific signature lines.
Fig. 5. Changing margin values for specific signature lines.

When RT tags are configured correctly, an empty placeholder and its accompanying text are removed without leaving any blank lines, as shown in Fig. 3. If you still see unwanted blank spaces in your signature, see the following examples of incorrect RT tag usage.

Examples of incorrect use of RT tags

It is possible to use the Remove if blank / Remove Text tag feature in a way that does not result in the expected behavior. See what to avoid in the examples below.

  1. Wrapping more than one placeholder
  2. Wrapping the start of a table

1. Wrapping more than one placeholder

In this example, more than one placeholder ({Phone} and {E-mail}) is surrounded by a single pair of RT tags:

{First name} {Last name}
{RT}Phone: {Phone}
E-mail: {E-mail}
{/RT}

With RT tags used as shown above, the entire content between {RT} and {/RT} will be displayed if at least one of the two placeholders has a specified value – even if the other has none. As a result, a blank space may be displayed in the signature instead of the user’s phone number or email address. The best practice is to use separate RT tags for each placeholder, as shown in Fig. 2.

2. Incorrect placement of RT tags in a table

If you select an entire table row and use the Remove if blank / Remove Text tag feature, that row will be removed if the placeholder is empty. However, if the opening tag is placed outside the table, as shown in Fig. 7., this can cause problems.

Incorrect placement of RT tags in a table.
Fig. 7. Incorrect placement of RT tags in a table.

If the attribute is empty for a given user, the RT tags remove the placeholder and its accompanying text as expected, but also break the table, as shown in Fig. 8.

Broken table in an email signature.
Fig. 8. Broken table in an email signature.

 

To fix this, move the opening tag inside the table, as shown in Fig. 9.

Correct placement of RT tags inside a table.
Fig. 9. Correct placement of RT tags inside a table.

 

Now, if the attribute is empty, the entire row is removed without breaking the table (Fig. 10.).

A table displayed correctly after removing an empty row.
Fig. 10. A table displayed correctly after removing an empty row.

How to use RT tags to automatically remove a table row that contains an empty placeholder

Remove Text tags can be used to remove certain HTML elements (syntax) if these elements include empty placeholders. A typical situation when you might want to automatically remove an element is when you use a signature based on an HTML table which contains various placeholders (Fig. 11.).

A sample signature based on a simple HTML table.
Fig. 11. A sample signature based on a simple HTML table.

Let’s assume that an email signature contains a table with two Entra ID / AD attribute placeholders, {Phone} and {Fax}, each in a separate row. When such a signature is added to emails, the {Phone} attribute placeholder is usually filled in for every sender, unlike the {Fax} field. To keep your signature layout clean, you can remove the entire table row with the fax number if this number is not populated with Entra ID / AD data (the sender’s Entra ID / Active Directory account has no Fax attribute). To do so, please follow the steps below:

Using RT tags in CodeTwo Email Signatures 365

In most cases, placing the opening RT tag at the start of a table row and the closing RT tag at the end of the row (see Fig. 9.) will correctly delete the entire row when there’s an empty placeholder between the tags. However, when the signature uses custom CSS styles, the table row might not be removed, leaving an empty row, as shown below (Fig. 12.).

An empty table row remaining after the placeholder is removed.
Fig. 12. An empty table row remaining after the placeholder is removed.

To ensure the entire row is removed, add RT tags directly to the HTML source code. To do this, open the HTML source code view in the signature template editor by clicking HTML source (Fig. 13., item 1). In the window that opens, insert RT tags by clicking Remove if blank (Fig. 13., item 2). Place the opening RT tag before the opening <tr> tag (Fig. 13., item 3) and the closing RT tag after the closing </tr> tag (Fig. 13., item 4).

Signature template editor – HTML source code view.
Fig. 13. Signature template editor – HTML source code view.

Troubleshooting

If the table row is not removed despite using Remove Text tags, try placing the tags inside HTML comments, as shown in Fig. 14.

Using RT tags inside HTML comments.
Fig. 14. Using RT tags inside HTML comments.

Using RT tags in CodeTwo email signature software for on-premises Exchange

This section applies to CodeTwo Email Signatures On-prem and the discontinued CodeTwo Exchange Rules family of products.

  1. Open your signature in the editor and switch to the HTML source code view by clicking the </> Source button on the ribbon.
  2. Find the <tr> element that defines the table row containing the placeholder you want to remove if empty.
  3. Select the entire <tr> element (including both the opening <tr> and closing </tr> tags, as highlighted in yellow in Fig. 15.) and click the Remove Text tag button. This will wrap the entire <tr> element in RT tags.
  4. Save your changes via the Apply & Close button in the source code view, then save the changes again in the editor’s window.

Using RT tags to remove parts of the HTML source code.
Fig. 15. Using RT tags to remove parts of the HTML source code.

From now on, if the value of your placeholder is missing, the entire row is removed without disrupting your signature layout. If you use the Remove Text tags to remove HTML elements, use the Preview button in the editor to review your changes before you apply them.

Was this information useful?
Our Customers: