Knowledge Base

How to create hyperlinks using Active Directory variables, and how to change their color


You would like to create hyperlinks that use values (attributes) from Active Directory. You would also like to change the color of these hyperlinks as they are blue by default.


See this section if you are using the following or newer versions CodeTwo Exchange Rules family software:

  • CodeTwo Exchange Rules Pro 2.x
  • CodeTwo Exchange Rules: 2019 1.x / 2016 1.x / 2013 2.x / 2010 3.x / 2007 4.x

See this section if you are using the following or older versions CodeTwo Exchange Rules family software:

  • CodeTwo Exchange Rules Pro 1.x
  • CodeTwo Exchange Rules: 2013 1.x / 2010 2.x / 2007 3.x

Solution for newer versions of CodeTwo Exchange Rules software (Pro 2.x, 2019 1.x, 2016 1.x, 2013 2.x, 2010 3.x, 2007 4.x):

In the current versions of CodeTwo products, AD attribute placeholders can be added directly to hyperlinks in the HTML source code view. To do that, you need to open the Editor, and then switch to the Source view.

Fig. 1. Switching to source code view.

Now, add the following code to the <body> section of signature:

<a href="mailto:{E-mail}" style="color: #f00;">Your text here</a>


  • mailto:{E-mail} stands for target of your hyperlink. You can also change it to any Web page address, e.g.
  • color: #f00; stands for your link color. You may also add more CSS attributes.
  • Your text here stands for visible text. It can also contain placeholders e.g. {E-mail}

After that you can switch again to the Designer view. Your link should now be red, as in the image below.

Fig. 2. Red hyperlink in Designer view.

If you want to remove the underline from the link, simply select it and click the Underline (U) button in the top menu. 

You can also consider hyperlinking an image instead of standard text. To do so, please follow the steps below:

  1. Use Picture button on the Editor's ribbon and add your image.
  2. Open Source view.
  3. Click that image and on the Editor's ribbon choose Insert hyperlink.
    Fig. 3. Adding hyperlink.
  4. Provide the desired URL (e.g. without any placeholders at this moment.
  5. Open the Source view and find the A tag responsible for hyperlinking your image.
  6. To the href attribute add requested placeholders. Let us assume that the main address is and we have a user named Howard Wilford. If you set the href attribute to the following:
    <A href="{First name}.{Last name}">
    it will change during processing of a message into:
    <A href="">
    Add hyperlinked AD placeholder
    Fig. 4. Adding placeholders.

Solution for older versions of CodeTwo Exchange Rules software (Pro 1.x, 2013 1.x, 2010 2.x, 2007 3.x):

In older versions of CodeTwo Exchange Rules 2007/2010/Pro, AD attribute values (placeholders) cannot be inserted directly into the hyperlinks. Instead, you need to build them from multiple parts by using the Rotating text placeholder (If you are not familiar with the concept, see this article). Moreover, linked Active Directory fields such as email as link in the signature editor are blue by default. Users can change links font type, style and size, but the color remains blue, as shown in the example in Fig. 5. The workaround that uses the Rotating text placeholder helps you with the color issue as well.

Fig. 5. Email as link dynamic fields remain blue in a default state despite applying color.

For the purpose of this article, let's say we want to insert into our footer an email address that is red instead of blue and is clickable. Normally, the signature would look like in the image in Fig. 6.

Fig. 6. Simple signature with the E-mail Dynamic field.

However, the dynamic field E-mail does not create a clickable link and E-mail as link field is always blue. Also, Exchange Rules editor does not recognize an HTML "mailto" link. We need to use Rotating text fields which are located in the Dynamic field menu (Fig. 7).

Fig. 7. Location of the Rotating Text field in the upper menu.

We need to "build" an HTML "mailto" link from parts of the code located in external source - files on the hard drive and from E-mail Dynamic field (as Dynamic fields work only when inserted directly in the editor).

An HTML "mailto" link could look like this one:

<A style="COLOR: #ff0000;" href="mailto:{E-mail}">{E-mail}</A>


Everything in the code except for E-mail Dynamic fields must be imported from external files. Let's create a proper structure of Dynamic Fields in the editor, as shown in Fig. 8.

Fig. 8. Structure of the Dynamic Fields in the footer prepared for "mailto" link building.

Next we need to prepare appropriate folders and files structure, as shown in Fig. 9If the CodeTwo software is installed on multiple Exchange servers, you need to create these folders in the same location (path) on each Exchange server.

Fig. 9. Folders and code source files structure on the hard drive.

Click on the first Rotating text field and using menu on the right point to a desired folder on the hard drive (Fig. 10).

Fig. 10. Linking {Rotating Text} fields with the code source files on the hard drive.

Save and close your editor and save your settings in the Administration module. Let's test our rule by sending a test email. Before that, make sure you have applied appropriate Conditions. The result should look more or less like this - link is red and clickable, works just like typical an HTML "mailto" link - Fig. 11.

Fig. 11. Signature with working red and clickable email address.

If you do not want the HTML "mailto" link to be underlined like the hyperlinks usually are, your hyperlink code must include "TEXT-DECORATION: none" attribute. So the full link code should look like this one:

<A style="COLOR: #ff0000; TEXT-DECORATION: none;" href="mailto:{E-mail}">{E-mail}</A>

Please be aware that the user Network Service must have appropriate permissions to the folder that stores your rotating text or rotating images folders and files. To do it, right click on the desired folder, choose Properties, Security tab and add Network Service user (Fig. 12) to the list with permission to Read & Execute (Fig. 13).

Fig. 12. Adding the Network Service user to the list of permissions.

Fig. 13. Adding appropriate permissions for the Network Service user.