• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 668
  • Last Modified:

Get HTML to pull information from AD to generate an email signature

Hi Experts,

I have created an HTML signature and worked hard on the format. Active directory attributes should be pulled in order to generate the signature details. when I run the code, I get the format I want but nothing is pulled from AD.

This code did run ok when I used as a disclaimer rule on office 365.

I have attached the code, can someone guide me on how to make the HTML code pull the attribute from AD.

I did connect to AD via powershell and tried to run the code but no luck.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">


<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

<title>Email Signature</title>




<div style="font-size:9pt;  font-family: 'Helvetica',sans-serif;">

<br> </br>

<p><strong><img src="https://www.mycompany.com/wp-content/uploads/2016/12/eb-logo-email-sig-01.png " width="174" height="37" alt="" /></strong></p><br>

<strong>%%Displayname%%</strong> / %%title%% <br>  

<a href="mailto:%%email%% "><font color="#D01f29">%%email%%</font></a><br />


<strong>%%Company%%</strong> <br>  

%%Phonenumber%% <br>  

%%Street%% <br>  

%%City%%, %%State%%,%%Zipcode%%, %%Country%% <br>  

<a href="https://www.mycompany.com/" target="_blank"><font color="#D01f29">www.company.com</font></a> <br />


<a href="https://twitter.com/company" target="_blank"><img src="https://s3.amazonaws.com/htmlsig-assets/round/twitter.png" alt="" width="24" height="24" border="0" /></a>&nbsp; <a href="https://www.facebook.com/companyinc" target="_blank"><img src="https://s3.amazonaws.com/htmlsig-assets/round/facebook.png" alt="" width="24" height="24" border="0" /></a>&nbsp; <a href="https://www.linkedin.com/company/3388?trk=tyah&amp;trkInfo=clickedVertical%3Acompany,clickedEntityId%3A33883,idx%3A2-1-4,tarId%3A1439926026058,tas%3Acompany" target="_blank"><img src="https://s3.amazonaws.com/htmlsig-assets/round/linkedin.png" alt="" width="24" height="24" border="0" /></a><br><br>

<em>This email may contain confidential  and/or proprietary information. Access to this e-mail by anyone other than the  intended recipient is unauthorised. If you are not the intended recipient (or responsible  for delivery of the message to such person), you may not use, copy, distribute  or deliver this message or any of its contents to anyone or take any action in  reliance on it</em>



Open in new window

Abbas Haidar
Abbas Haidar
3 Solutions
Hi there,

Can you confirm where you are running the code please? You mentioned it worked in an Office 365 transport rule and as this question is tagged with ‘Office 365’, we just want to find out where this is not working.

All the best,

Abbas HaidarAuthor Commented:
Basically, the aim is to get the users to run the .html code in order to generate their email signature on their desktop ( office 365 was an example to prove that the code works if connected to AD, I will take that tag out). It will be ideal to have this as a page where a user enter his username and password and it will generate his signature according to his AD credentials.
Unfortunately the above will not work. It will simply open a HTML page showing either the design or the flat code. You won't be able to simply run an HTML file like you can a PowerShell command. To run something like this over PowerShell, you will need to use PowerShell commands to query your AD and build your signature.

You could always try one of our email signature solutions to do make this process easier if you were interested in looking at a third-party product.

Evaluating UTMs? Here's what you need to know!

Evaluating a UTM appliance and vendor can prove to be an overwhelming exercise.  How can you make sure that you're getting the security that your organization needs without breaking the bank? Check out our UTM Buyer's Guide for more information on what you should be looking for!

Abbas HaidarAuthor Commented:
Thank you, I dont want to use a third party. I am looking to use PowerShell commands to query AD and build your signature using the html format as an output. is that possible?
CodeTwo SoftwareSoftware DeveloperCommented:
Hi Abbas,

It will be ideal to have this as a page where a user enter his username and password and it will generate his signature according to his AD credentials.

This sounds like it would require a whole online application. Before you go this route, see if the VBS solution mentioned by Shaun is close enough.

Alternatively, you could try this:

1. Deploy an Office 365 disclaimer using your code (http://mail-signatures.com/articles/configuring-organization-wide-email-signatures-in-office-365/?sts=6614), but configure it to be added only to the first email.

You can do this by defining an exception: Except If > The subject or body matches these text patterns > "This email may contain confidential  and/or proprietary information"

2: Ask users to send 1 email to themselves and copy the disclaimer into the email signature box on their email clients BUT set it to add only to replies and forwards (https://www.groovypost.com/tips/outlook-make-signature-display-replying-forwarding-email/)

You can also send this email automatically using PowerShell:

foreach ($AllMailboxes in (Get-Mailbox)) { $Name=$AllMailboxes.Name; $UserSMTP=$AllMailboxes.PrimarySmtpAddress; send-mailmessage -to "$Name <$UserSMTP>" -from "$Name <$UserSMTP>" -subject "Email signature + instructions" -bodyasHTML -body "%instructions%" -smtpServer %Your SMTP server FQDN% }

Open in new window

Best regards,

Featured Post

Will You Be GDPR Compliant by 5/28/2018?

GDPR? That's a regulation for the European Union. But, if you collect data from customers or employees within the EU, then you need to know about GDPR and make sure your organization is compliant by May 2018. Check out our preparation checklist to make sure you're on track today!

Tackle projects and never again get stuck behind a technical roadblock.
Join Now