This week, I was presented with a fun project that had nothing at all to do with migrating workloads to the cloud. One of the VP’s of the company I work for decided he wanted to have everyone use the same Email Signature. Typically, at previous companies, an edict was issued via email telling everyone to change their signatures, and they included a sample of what the signature needed to look like. Sometimes this works OK, more than likely though, people either don’t pay attention to the email, or decide not to do it.
Behind the scenes, an email signature is just an .htm file with all of the necessary formatting in it. Typically it contains your phone number, address, email address and a few other things. When you create your email signature in Outlook, it creates an htm file and stores it in %appdata%\Microsoft\Signatures. Knowing it is just an .htm file, my first step was visiting our Web Designer because I don’t really know HTML that well and didn’t really have the time to figure it out. But, I have friends that know that stuff like the back of their hand, and in no time we had the design all figured out.
The next step was to go through the HTML code and find all of the variables that needed to change from user to user, items like Phone Number, Display Name, Email Address, etc. all need to be unique to each user. So I went through the code and found where the email address field was and replaced it with %%Email%%, Phone Number with %%PhoneNumber%%, Name with %%DisplayName%%. Whats up with the %%Variable%% you may ask? Well it’s easy, the first thing I wanted to try was to add the new signature via a Disclaimer Transport rule, and those are the some of the variables that relate to Transport Rules.
The Disclaimer Transport Rule worked great when sending the first email, but if you were replying to an email, etc, your signature would show up at the bottom of the entire Email thread. So this wasn’t going to work. For those of you who might be wondering, I only applied the transport rule to me, not the whole company.
After thinking about it more, ultimately I came up with a Powershell Script to be run at Logon that copies a Signature template file to the users hard drive, then it reads in the template file and replaces all of the variables with values and writes a new file called signature.htm. When it is done with all that, it makes the appropriate registry changes in Office 2016 to set the signature as mandatory. I also added code so when we change the template file again, it is just a matter of replacing the template file on the share. If a new file is detected, the process starts over again.
Doing something like this wasn’t hard by any means, it only took a few hours if that. It was enjoyable though because it was something totally different than the day-to-day migration stuff I typically do.
Below is the link to the two files, the Template file and the PowerShell script used to create the Signature file.