# HTML Script For Company Wide Email Signatures

We are trying to roll out company wide email signatures for employees using an html script to be deployed via GPO or other means if easier.

We would like a simple script that pulls employee information for active directory: name, title, phone number, fax, company name, company confidentially agreement. possibly logo.

Our environment is a mix of Office 2010 and 2016, Exchange 2013, Server 2012 R2, and a mix of windows 7 and windows 10 machines.

Thank you.
###### Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Software DeveloperCommented:
Perhaps some third-party product would be better than constant deployment of email signatures (that are being changed from time to time). Please take a look at CodeTwo Exchange Rules product that works directly on Exchange and allows to add professional email signatures on the fly. It supports all kind of devices and its installation is very easy.

Also, the software is equipped with WYSIWYG HTML editor and allows to set different signatures for different departments.
0
Sr Solutions ArchitectCommented:
https://technet.microsoft.com/en-us/library/dn600437(v=exchg.150).aspx covers how to force signatures with a transport rule in Exchange. This is an effective way to make certain that signatures are appended to emails even if users don't have them set up in outlook. The caveat here is that you will get duplicate signatures if they aren't set up correctly, and the signature can end up appearing in weird places in replies.

Aside from that method, there are third party solutions for managing organizational signatures. CodeTwo has a good one here: https://www.codetwo.com/guides/email-signatures-on-exchange

There's also a very complicated GPO-based method here: https://community.spiceworks.com/how_to/121772-how-to-deploy-signatures-with-gpo-for-outlook-2013
0
Author Commented:
It will not be edited once in place.

The guidelines for the email signatures are as follows: FONT: Calibri, size 11 in black---both for new email and reply (no blue reply). No wallpaper background.

need the following items added in.

Name (bold)
title, Company name
work number, fax number
0
I have used the following vbs to create an html sig, you may need to edit

Set objUser = CreateObject("WScript.Network")
domainName = objUser.UserDomain

FUNCTION GetUserDN(BYVAL UN, BYVAL DN)
Set ObjTrans = CreateObject("NameTranslate")
objTrans.init 1, DN
objTrans.set 3, DN & "\" & UN
strUserDN = objTrans.Get(1)
GetUserDN = strUserDN
END FUNCTION

Set objLDAPUser = GetObject("LDAP://" & GetUserDN(userName,domainName))

'Prepare to create some files
Dim strNew
Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile,plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath, website
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
pathToCopyTo = appDataPath & "\Microsoft\Signatures\"
website = "www.yourwebsite.com"

' This section checks if the signature directory exists and if not creates one.
'==========================================================================
Dim objFS1
Set objFS1 = CreateObject("Scripting.FileSystemObject")
If (objFS1.FolderExists(pathToCopyTo)) Then
Else
Call objFS1.CreateFolder(pathToCopyTo)
End if

'Let's create the plain text signature
plainTextFilePath = pathToCopyTo & "Default.txt"
Set plainTextFile = objFSO.CreateTextFile(plainTextFilePath, TRUE)
plainTextFile.WriteLine("--------------------------- ")
plainTextFile.WriteLine(objLDAPUser.DisplayName)
plainTextFile.WriteLine(objLDAPUser.title)
plainTextFile.WriteLine(objLDAPUser.company)
plainTextFile.WriteLine(objLDAPUser.l)
plainTextFile.WriteLine("Telephone: " & objLDAPUser.telephoneNumber)
plainTextFile.WriteLine("Fax: " & objLDAPUser.facsimileTelephoneNumber)
plainTextFile.WriteLine("Email: " & objLDAPUser.mail)
plainTextFile.Write("Website: " & objLDAPUser.wWWHomePage)
plainTextFile.Close

'Now we create the Rich Text signature
richTextFilePath = pathToCopyTo & "Default.rtf"
Set richTextFile = objFSO.CreateTextFile(richTextFilePath, TRUE)
richTextFile.WriteLine("{\rtf1\ansi\ansicpg1252\deff0\deflang2057{\fonttbl{\f0\fswiss\fcharset0Arial;}}")
richTextFile.WriteLine("\viewkind4\uc1\pard\f0\fs20 ---------------------- \par")
richTextFile.WriteLine(objLDAPUser.DisplayName & "\par")
richTextFile.WriteLine(objLDAPUser.title & "\par")
richTextFile.WriteLine(objLDAPUser.company & "\par")
richTextFile.WriteLine(objLDAPUser.l & "\par")
richTextFile.WriteLine("Telephone: " & objLDAPUser.telephoneNumber & "\par")
richTextFile.WriteLine("Fax: " & objLDAPUser.facsimileTelephoneNumber & "\par")
richTextFile.WriteLine("Email: " & objLDAPUser.mail & "\par")
richTextFile.WriteLine("Website: " & objLDAPUser.wWWHomePage & "\par")
richTextFile.Write("}")
richTextFile.Close

'And finally, the HTML signature
htmlFilePath = pathToCopyTo & "Default.htm"
Set htmlFile = objFSO.CreateTextFile(htmlFilePath, TRUE)
htmlfile.WriteLine("<!DOCTYPE html PUBLIC ""-//W3C//DTD XHTML 1.0Transitional//EN""""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"">")
htmlfile.WriteLine("<html xmlns=""http://www.w3.org/1999/xhtml"" >")
htmlfile.WriteLine("<body>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:'Arial','helvetica';"">")
htmlfile.WriteLine("<div>____________________ </div>")
htmlfile.WriteLine("<div style='font-family:Arial;font-size:12pt;color:blue;font-weight:bold'>" & objLDAPUser.DisplayName & "</div>")
htmlfile.WriteLine("<div>" & objLDAPUser.title & "</div>")
htmlfile.WriteLine("<div>" & objLDAPUser.company & "</div>")
htmlfile.WriteLine("<div>" & objLDAPUser.streetAddress & "</div>")
htmlfile.WriteLine("<div>" & objLDAPUser.l & "," & objLDAPUser.st & " " & objLDAPUser.postalCode & "</div>")
htmlfile.WriteLine("<div>Telephone: " & objLDAPUser.telephoneNumber & "</div>")
htmlfile.WriteLine("<div>Fax: " & objLDAPUser.facsimileTelephoneNumber & "</div>")
htmlfile.WriteLine("<div>Cell: " & objLDAPUser.mobile & "</div>")
htmlfile.WriteLine("<div>Email: <a href="" & objLDAPUser.mail & "">" &objLDAPUser.mail & "</a></div>")
htmlfile.WriteLine("<div>Website:<a href=""www.yourwebsite.com"">" &website & "</a></div>")
htmlfile.WriteLine("		<br/>")
htmlfile.WriteLine("		<br/>")
htmlfile.WriteLine("		<br/>")
htmlfile.WriteLine("		<br/>")
htmlfile.WriteLine("<td><a href=http://www.yourwebsite.com/><img src=file:///\\path\to\your\Logo.jpg></a></td>")
htmlfile.WriteLine("</div>")
htmlfile.WriteLine("<div>This message (including any attachments) may contain confidential information and is intended only for the individual to which it is addressed. If you are not the intended recipient, please delete this message and contact the sender. You are also hereby notified that any review, disclosure, copying, or distribution of this message, or the taking of any action based on it, is prohibited. </div>")
htmlfile.WriteLine("</body>")
htmlfile.Write("</html>")

Dim objShell, RegKey, RegKeyParm
Set objShell = CreateObject("WScript.Shell")
RegKey = "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General"
RegKey = RegKey & "\Signatures"
objShell.RegWrite RegKey , "Signatures"
UserDataPath = ObjShell.ExpandEnvironmentStrings("%appdata%")
FolderLocation = UserDataPath &"\Microsoft\Signatures\"
HTMFileString = FolderLocation & "Default.htm"

' This section disables the change of the signature by the user.
'====================
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\NewSignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\ReplySignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Mail\EditorPreference" , "131073" , "REG_DWORD"

objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EditorPreference" , "131072" , "REG_DWORD"

'Set default signature to new mail and none for replies and forwards

strNew = Array(68,0,101,0,102,0,97,0,117,0,108,0,116,0,0,0)

const HKEY_CURRENT_USER = &H80000001
strComputer = "."

Set oReg=GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &_
strComputer & "\root\default:StdRegProv")

strKeyPath = "Software\Microsoft\Windows NT\CurrentVersion\Windows Messaging Subsystem\Profiles\Outlook\9375CFF0413111d3B88A00104B2A6676\00000004"

strValueName = "Reply-Forward Signature"
oReg.SetBinaryValue HKEY_CURRENT_USER,strKeyPath & "\" & subkey, strValueName,strValue

strValueName = "New Signature"
strValue=StrNew
oReg.SetBinaryValue HKEY_CURRENT_USER,strKeyPath & "\" & subkey, strValueName,strValue


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Author Commented:
Hey Donald,

I tried to edit this script to what I need.
how did you execute the script? Using gpo?
0
Thru ADUC under users profile tab --> logon script. To do this to multiple users at once you can highlight them all --> Right Click--> Properties--> Profile tab--> Logon Script.
0
Side note: Be sure that the logo if used is accessible to external users. I ran into issues where email was getting flagged as spam because of a link within the email pointed to a location that couldn't be reached.
0
Author Commented:
We want a very basic signature, maybe add one photo later during the holidays....

I have created some HTML code I want to use (below) that works when doing transport rules in ECP, but it is very limited in formatting and never shows in the body of the most recent message.

I would like to use this code as you are suggesting in a script but not sure how or if this will link to ADUC and pull the information that I want.

*Forgive me, my coding background is very very limited.

'' works for transport rule in ECP''

</br>
</br>
<div style="font-size:11pt;  font-family: 'Calibri',sans-serif;">
<b>%%displayname%%</b></br>
%%title%% , %%company%%</br>
%%street%%, %%city%%, %%state%% %%zipcode%%</br>
Phone: %%Phone%% , Fax: %%Fax%%</br>
%%notes%%
</div>
0
The script does pull all the info you mentioned and creates three files to be used for signature: Plain txt, rich text, and html

Name (bold)
title, Company name
work number, fax number
0
Author Commented:
Okay good,

So do I need to add anything else to it before I link it to a gpo? I feel like I need extra parameters in order for exchange to pull this information out of ADUC as an email signature.
0
Sorry, I didn't create/write the script. I just edited to my liking. I would just test it on yourself and see how it looks.

For example from the script

plainTextFile.WriteLine(objLDAPUser.DisplayName)  ---->Pulls "Display Name" from general tab of users AD properties
plainTextFile.WriteLine(objLDAPUser.title)                   ---->Pulls "Job Title" from the organization tab
plainTextFile.WriteLine(objLDAPUser.company)         ---->Pulls "Company" from the organization tab
plainTextFile.WriteLine(objLDAPUser.streetAddress) ---->Pulls "Street" from the Address tab

And....so on
0
When I was editing I just looked up items as follows

https://community.spiceworks.com/topic/82846-list-of-objldapuser-variables
0
Author Commented:
I got some code working as a VB script, it has everything that need in it. but is there a way to render vbs as html or convert vbs to html?
0
I'm not sure I'm following you. When you run the vbs provided it creates the signatures for you with data it pulls from AD. Did you try it ??
0
Author Commented:
Yes that is correct. I have it working as I want now, a vbscript that is pushed out via gpo. however it is showing as plain text, how I do I write it in html
0
It should be writing it in all 3 formats. Look in the folder

C:\Users\<USER>\AppData\Roaming\Microsoft\Signatures
0
There should be a default.html, default.rtf, and a default.txt
0
Solutions ArchitectCommented:
No comment has been added to this question in more than 21 days, so it is now classified as abandoned.

I have recommended this question be closed as follows:

Split:
-- Donald Stewart (https:#a42356539)
-- CodeTwo Software (https:#a42354107)
-- Adam Brown (https:#a42354113)

If you feel this question should be closed differently, post an objection and the moderators will review all objections and close it as they feel fit. If no one objects, this question will be closed automatically the way described above.

Pber
Experts-Exchange Cleanup Volunteer
0
###### It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Office

From novice to tech pro — start learning today.