In a HTML email signature is there way to conditionally hide content?

0

[I've asked this on StackOverflow and was advised to put it on here.]

I have created a HTML email signature, in Exchange Admin Center, that uses variables to get data from active directory. But, if any of these variables are empty the signature displays a blank space.

Is there any way - preferably without javascript (if possible) - to say if the variable is empty/null then don't display that line of content.

For example, if the email field is empty the signature will display 'E: [blank space]'. I'd rather it not display the Email line. The images are probably more helpful.

Here is the code [snippet] I'm using in the signature that I want to put conditions on...

<div class="all-info" style="float: left; padding-left: 5px;padding-top: 15px">
   <h3 style="margin: 0px; color: #DB0E15">%%FirstName%% %%LastName%%</h3>
   <h4 style="margin: 0px; padding: 3px 0px 6px 0px;">%%title%%</h4>
   <h5 style="margin: 0px; padding-bottom: 5px;"><span style="color: #DB0E15">E : </span>%%email%%</h5>
   <h5 style="margin: 0px; padding-bottom: 3px;"><span style="color: #DB0E15">T : </span>%%PhoneNumber%%</h5>
</div>

Note: It needs to work in Outlook as well as other clients/browsers.

Below are images to try and explain my problem better.

Signature when email not blank

Notice in this image, the line with email content is displayed with a blank email address. Which is when I don't want the line to appear.

Signature with blank email - don't want this line appearing

Here is the HTML I am using...

<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <title></title>
    <style type="text/css">
        table td { border-collapse: collapse; }
        .msoBord { mso-table-lspace:-1pt; mso-table-rspace:-1pt; border-right-color: #DB0E15; border-right-style: solid; border-right-width: medium;}
        .msoFix { mso-table-lspace:-1pt; mso-table-rspace:-1pt;}
    </style>
</head>
<body style="margin: 0px; padding: 0px; background-color: white;" bgcolor="white">
    <font face="Arial">
        <table width="100%" border="0" cellpadding="0" cellspacing="0">
          <tr>
            <td align="left">
              <div style="max-width:700px !important;">
                <table class="msoBord" width="120" cellpadding="0" cellspacing="0" align="left" bgcolor="white" >
                  <tr>
                    <td align="left" style="padding: 0px;">
                    <a href="https://[our.web.address]/"><img src="[link to image]" alt=""></a>
                    </td>
                  </tr>
                </table>
                <table class="msoFix" width="380" cellpadding="0" cellspacing="0" align="left" bgcolor="white">
                  <tr>
                    <td align="left" style="padding: 5px;">
                    <div class="all-info" style="float: left; padding-left: 5px;padding-top: 15px">
                        <h3 style="margin: 0px; color: #DB0E15">%%FirstName%% %%LastName%%</h3>
                        <h4 style="margin: 0px; padding: 3px 0px 6px 0px;">%%title%%</h4>
                        <h5 style="margin: 0px; padding-bottom: 5px;"><span style="color: #DB0E15">E : </span>%%email%%</h5>
                        <h5 style="margin: 0px; padding-bottom: 3px;"><span style="color: #DB0E15">T : </span>%%PhoneNumber%%</h5>
                    </div>
                    </td>
                  </tr>
                </table>
              </div>
            </td>
          </tr>
        </table>
    </font>
</body>

Matt

Posted 2019-11-20T14:19:38.613

Reputation: 81

Can you use a script to auto-generate the signature file? If so you could put some logic in there to decide whether to put the line in or not maybe? – Smock – 2019-11-20T14:23:19.893

It's not a file. It's just HTML code put into Exchange. – Matt – 2019-11-20T14:25:21.723

How is it put in? via a script? textbox? is this setting a default sig? – Smock – 2019-11-20T14:26:54.170

The latter. Default sig. – Matt – 2019-11-20T14:27:37.227

Javascript must be executed on the client side, but JS is not executed for HTML emails — that'd be rather complex, and a huge security issue. The only way to deal with it is to not generate it in the first place. Possibly third-party tools like https://www.codetwo.com/exchange-rules-family/ can do that.

– slhck – 2019-11-20T14:39:36.420

1

From what I can see this is a known issue with setting signatures in the disclaimer field in exchange (I'm guessing this is what you're doing), and can be fixed only with 3rd party tools like the two linked here. Alternatively you could use group policy to generate a signature on logon instead.

– Smock – 2019-11-20T14:39:58.833

@Smock Thanks!! – Matt – 2019-11-20T15:40:56.280

No answers