[Update]: This article was updated on July 26, 2021.
In one of my previous articles, I’ve shown how to create simple email signatures in Outlook using VBScript. In this article, I will show you how to take your email signatures to a higher level. I will use VBScript to create an HTML email signature for every Outlook (for Windows) installation in your organization. The script will create a professional email signature with data taken from Active Directory. Next, I will explain how to use GPO to distribute the script to every user in your organization.
- Creating HTML with VBScript
- Sample VBScripts
- Creating your own script
- Deploying the script for a single user
- Deploying the script for multiple users
- Professional email signature management
Creating HTML with VBScript
Before you proceed, a short explanation about creating an HTML file with VBScript. Both VBScript and HTML languages use double quotation marks (“) as the default characters for specifying data input. That generates a problem, at least in this scenario. If you try to use single quotation marks for data input in VBScript, you will end up in converting the entire script into a single huge comment. There are two methods which will let us work around this issue:
- Adding & “”” after each double quotation mark found in HTML code (method used in Script 1). Just be sure to add a space before the & character as well.
- Changing all double quotation marks to single quotation marks in HTML code (method used in Script 2).
I prefer method 2, as it results in a cleaner code and it’s easy to use e.g. Notepad to replace all ” with ‘ in a source HTML file.
In addition to those methods, you could use only a single WriteLine method and create one-line HTML code. Although it might make the method used in Script 2 slightly easier, you will greatly decrease readability of your code.
Sample VBScripts
First, you need to create a script which will create a personalized HTML email signature for each user. Below, I will present two different sample scripts which create two different signature templates. Those samples use slightly different methods to generate HTML code.
The base HTML code for signature templates originates from the free email signature generator.
Important! Both scripts include a section with global placeholders. They relate to data that should be identical for every user (company address, social media websites, etc.). Make sure to replace their values with your company’s data.
Script 1
The first sample script will let you create the following signature template:
Click to expand/hide Script 1On Error Resume Next 'Setting up the script to work with the file system. Set WshShell = WScript.CreateObject("WScript.Shell") Set FileSysObj = CreateObject("Scripting.FileSystemObject") 'Connecting to Active Directory to get user’s data. Set objSysInfo = CreateObject("ADSystemInfo") Set UserObj = GetObject("LDAP://" & objSysInfo.UserName) strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%") SigFolder = StrAppData & "\Microsoft\Signatures\" SigFile = SigFolder & UserObj.sAMAccountName & "1.htm" 'Setting placeholders for the signature. strUserName = UserObj.sAMAccountName strFullName = UserObj.displayname strTitle = UserObj.title strMobile = UserObj.mobile strEmail = UserObj.mail strCompany = UserObj.company strOfficePhone = UserObj.telephoneNumber 'Setting global placeholders for the signature. Those values will be identical for all users - make sure to replace them with the right values! strCompanyLogo = """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/logo.png" strCompanyAddress1 = "16 Freedom St, Deer Hill" strCompanyAddress2 = "58-500 Poland" strWebsite = """https://www.my-company.com" strFacebook = """https://www.facebook.com/" strTwitter = """https://www.twitter.com/" strYouTube = """https://www.youtube.com/" strLinkedIn = """https://www.linkedin.com/" strInstagram = """https://www.instagram.com/" strPinterest = """https://www.pinterest.com/" 'Creating HTM signature file for the user's profile, if the file with such a name is found, it will be overwritten. Set CreateSigFile = FileSysObj.CreateTextFile (SigFile, True, True) 'Signature’s HTML code. CreateSigFile.WriteLine "<!DOCTYPE HTML PUBLIC " & """-//W3C//DTD HTML 4.0 Transitional//EN" & """>" CreateSigFile.WriteLine "<HTML><HEAD><TITLE>Email Signature</TITLE>" CreateSigFile.WriteLine "<META content=" & """text/html; charset=utf-8" & """ http-equiv=" & """Content-Type" & """>" CreateSigFile.WriteLine "</HEAD>" CreateSigFile.WriteLine "<BODY style=" & """font-size: 10pt; font-family: Arial, sans-serif;" & """>" CreateSigFile.Writeline "<table style=" & """width: 420px; font-size: 10pt; font-family: Arial, sans-serif;" & """ cellpadding=" & """0" & """ cellspacing=" & """0" & """>" CreateSigFile.Writeline "<tbody>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td width=" & """130" & """ style=" & """font-size: 10pt; font-family: Arial, sans-serif; border-right: 1px solid; border-right-color: #008080; width: 130px; padding-right: 10px; vertical-align: top;" & """ valign=" & """top" & """ rowspan=" & """6" & """> <a href=" & strWebsite & """ target=" & """_blank" & """><img border=" & """0" & """ alt=" & """Logo" & """ width=" & """110" & """ style=" & """width:110px; height:auto; border:0;" & """ src=" & strCompanyLogo & """></a>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "<td>" CreateSigFile.Writeline "<table cellpadding="& """0"& """ cellspacing="& """0"& """>" CreateSigFile.Writeline "<tbody>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td style="& """font-size: 10pt; color:#0079ac; font-family: Arial, sans-serif; width: 305px; padding-bottom: 5px; padding-left: 10px; vertical-align: top; line-height:25px;"& """ valign="& """top"& """>" CreateSigFile.Writeline "<strong><span style="& """font-size: 14pt; font-family: Arial, sans-serif; color:#008080;"& """>" & strFullName & "<br></span></strong>" CreateSigFile.Writeline "<span style="& """font-family: Arial, sans-serif; font-size:10pt; color:#545454;"& """>" & strTitle & "</span>" CreateSigFile.Writeline "<span style="& """font-family: Arial, sans-serif; font-size:10pt; color:#545454;"& """> | </span>" CreateSigFile.Writeline "<span style="& """font-family: Arial, sans-serif; font-size:10pt; color:#545454;"& """>" & strCompany & "</span>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "</tr>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td style="& """font-size: 10pt; color:#444444; font-family: Arial, sans-serif; padding-bottom: 5px; padding-top: 5px; padding-left: 10px; vertical-align: top;"& """ valign="& """top"& """>" CreateSigFile.Writeline "<span><span style="& """color: #008080;"& """><strong>m:</strong></span><span style="& """font-size: 10pt; font-family: Arial, sans-serif; color:#545454;"& """>" & strMobile & "<br></span></span>" CreateSigFile.Writeline "<span><span style="& """color: #008080;"& """><strong>p:</strong></span><span style="& """font-size: 10pt; font-family: Arial, sans-serif; color:#545454;"& """>" & strOfficePhone & "<br></span></span>" CreateSigFile.Writeline "<span><span style="& """color: #008080;"& """><strong>e:</strong></span><span style="& """font-size: 10pt; font-family: Arial, sans-serif; color:#545454;"& """>" & strEmail& "</span></span>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "</tr>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td style="& """font-size: 10pt; font-family: Arial, sans-serif; padding-bottom: 5px; padding-top: 5px; padding-left: 10px; vertical-align: top; color: #0079ac;"& """ valign="& """top"& """>" CreateSigFile.Writeline "<span style="& """font-size: 10pt; font-family: Arial, sans-serif; color: #008080;"& """>" & strCompanyAddress1 & "<span><br></span></span>" CreateSigFile.Writeline "<span style="& """font-size: 10pt; font-family: Arial, sans-serif; color: #008080;"& """>" & strCompanyAddress2 &"</span>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "</tr>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td style="& """font-size: 10pt; font-family: Arial, sans-serif; padding-bottom: 5px; padding-top: 5px; padding-left: 10px; vertical-align: top; color: #0079ac;"& """ valign="& """top"& """>" CreateSigFile.Writeline "<a href="& """https://www.my-company.com"& """ target="& """_blank"& """ rel="& """noopener"& """ style="& """text-decoration:none;"& """><span style="& """font-size: 10pt; font-family: Arial, sans-serif; color: #008080;"& """>www.my-company.com</span></a>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "</tr>" CreateSigFile.Writeline "<tr>" CreateSigFile.Writeline "<td style="& """font-size: 10pt; font-family: Arial, sans-serif; padding-bottom: 5px; padding-top: 5px; padding-left: 10px; vertical-align: top;"& """ valign="& """top"& """>" CreateSigFile.Writeline "<span><a href="& strFacebook & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """facebook icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/fb.png"& """></a> </span><span><a href="& strTwitter & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """twitter icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/tt.png"& """></a> </span><span><a href="& strYouTube & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """youtube icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/yt.png"& """></a> </span><span><a href="& strLinkedIn & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """linkedin icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/ln.png"& """></a> </span><span><a href="& strInstagram & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """instagram icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/it.png"& """></a> </span><span><a href="& strPinterest & """ target="& """_blank"& """ rel="& """noopener"& """><img border="& """0"& """ width="& """21"& """ alt="& """pinterest icon"& """ style="& """border:0; height:21px; width:21px"& """ src="& """https://codetwocdn.azureedge.net/images/mail-signatures/generator-dm/simplephoto-with-logo/pt.png"& """></a></span>" CreateSigFile.Writeline "</td>" CreateSigFile.Writeline "</tr>" CreateSigFile.Close 'Applying the signature in Outlook’s settings. Set objWord = CreateObject("Word.Application") Set objSignatureObjects = objWord.EmailOptions.EmailSignature 'Setting the signature as default for new messages. objSignatureObjects.NewMessageSignature = strUserName & "1" 'Setting the signature as default for replies & forwards. objSignatureObjects.ReplyMessageSignature = strUserName & "1" objWord.Quit
Script 2
The script below lets you create the following signature template:
Click to expand/hide Script 2On Error Resume Next 'Setting up the script to work with the file system. Set WshShell = WScript.CreateObject("WScript.Shell") Set FileSysObj = CreateObject("Scripting.FileSystemObject") Set objSysInfo = CreateObject("ADSystemInfo") Set UserObj = GetObject("LDAP://" & objSysInfo.UserName) strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%") SigFolder = StrAppData & "\Microsoft\Signatures\" SigFile = SigFolder & UserObj.sAMAccountName & "2" & ".htm" 'Setting placeholders for the signature. They will be automatically replaced with data from Active Directory. strUserName = UserObj.sAMAccountName strFullName = UserObj.displayname strTitle = UserObj.title strMobile = UserObj.mobile strEmail = UserObj.mail strCompany = UserObj.company strOfficePhone = UserObj.telephoneNumber 'Setting global placeholders for the signature. Those values will be identical for all users - make sure to replace them with the right values! strCompanyLogo = "https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/logo.png" strBanner = "https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/banner.png" strBannerLinkingTo = "https://www.codetwo.com/email-signatures/" strCompanyAddress = "16 Freedom St, Deer Hill 58-500 Poland" strWebsite = "www.my-company.com" strFacebook = "https://www.facebook.com/" strTwitter = "https://www.twitter.com/" strYouTube = "" strLinkedIn = "https://www.linkedin.com/" strInstagram = "https://www.instagram.com/" strPinterest = "" 'Creating HTM signature file for the user's profile. Set CreateSigFile = FileSysObj.CreateTextFile (SigFile, True, True) 'Signature’s HTML code CreateSigFile.WriteLine "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.0 Transitional//EN'>" CreateSigFile.WriteLine "<HTML><HEAD><TITLE>Email Signature</TITLE>" CreateSigFile.WriteLine "<META content='text/html; charset=utf-8' http-equiv='Content-Type'>" CreateSigFile.WriteLine "</HEAD>" CreateSigFile.WriteLine "<BODY style='font-size: 10pt; font-family: Arial, sans-serif;'>" CreateSigFile.WriteLine "<table width='480' style='font-size: 11pt; font-family: Arial, sans-serif;' cellpadding='0' cellspacing='0' border='0'>" CreateSigFile.WriteLine "<tbody>" CreateSigFile.WriteLine "<tr>" CreateSigFile.WriteLine "<td width='160' style='font-size: 10pt; font-family: Arial, sans-serif; width: 160px; vertical-align: top;' valign='top'> <a href='https://www.my-company.com/' target='_blank'><img border='0' alt='Logo' width='125' style='width:125px; height:auto; border:0;' src='" & strCompanyLogo & "'></a>" CreateSigFile.WriteLine "</td>" CreateSigFile.WriteLine "<td valign='top' width='270' style='width:270px; vertical-align: top; line-height:11px; border-right:2px solid #29abe1'><table cellpadding='0' cellspacing='0' border='0' width='270'><tbody> <tr> <td style='font-size:12pt; height:14px; line-height:14px'><strong style='font-family: Arial, sans-serif;font-size: 12pt;color:#29abe1;'>" & strFullName & "</strong></td> </tr> <tr> <td style='font-size:9pt; height:14px; line-height:14px'> <span style='font-family: Arial, sans-serif; font-size:9pt; color:#000000;'>" & strTitle & "</span> <span style='font-family: Arial, sans-serif; font-size:9pt; color:#000000;'> |" & strCompany & "</span> </td> </tr> <tr> <td style='height:14px; line-height:14px'> </td> </tr> <tr> <td style='font-size:9pt; height:14px; line-height:14px'> <span style='font-family: Arial, sans-serif;color:#000000;FONT-SIZE: 9pt'><strong>M</strong> " & strMobile & "</span> <span style='font-family: Arial, sans-serif;color:#000000;FONT-SIZE: 9pt'> | <strong>P</strong> " & strOfficePhone & "</span> </td> </tr> <tr> <td style='font-size:9pt; height:12px; line-height:12px'> <span style='font-family: Arial, sans-serif;color:#000000;FONT-SIZE: 9pt'><strong>E</strong> " & strEmail & "</span> </td> </tr> <tr> <td style='height:14px; line-height:14px'> </td> </tr> <tr> <td style='font-size:9pt; height:12px; line-height:12px'> <span style='font-family: Arial, sans-serif;color:#000000;FONT-SIZE: 9pt'>" & strCompanyAddress & "</span> </td> </tr> <tr> <td style='font-size:9pt; height:12px; line-height:12px'> <span><a href='https://" & strWebsite & "' target='_blank' rel='noopener' style=' text-decoration:none;'><strong style='color:#29abe1; font-family:Arial, sans-serif; font-size:9pt'>" & strWebsite & "</strong></a></span> </td> </tr> </tbody><tbody> </tbody></table>" CreateSigFile.WriteLine "</td>" CreateSigFile.WriteLine "<td style='vertical-align: top; padding-left:10px' valign='top' width='35'> <table cellpadding='0' cellspacing='0' border='0' width='25'> <tbody>" If strFacebook <> "" Then CreateSigFile.WriteLine "<tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='" & strFacebook & "' target='_blank' rel='noopener'><img border='0' width='26' height='25' alt='facebook icon' style='border:0; height:25px; width:26px;' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/fb.png'></a></td></tr>" End If If strTwitter <> "" Then CreateSigFile.WriteLine "<tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='" & strTwitter & "' target='_blank' rel='noopener'><img border='0' width='26' height='25' alt='twitter icon' style='border:0; height:25px; width:26px;' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/tt.png'></a></td></tr>" End If If strYouTube <> "" Then CreateSigFile.WriteLine "<tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='"& strYouTube &"' target='_blank' rel='noopene r'><img border='0' width='26' height='25' alt='youtube icon' style='border:0; height:25px; width:26px' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/yt.png'></a></td> </tr>" End If CreateSigFile.WriteLine "</tbody></table>" CreateSigFile.WriteLine "</td>" CreateSigFile.WriteLine "<td style='vertical-align: top;' valign='top' width='25'>" CreateSigFile.WriteLine "<table cellpadding='0' cellspacing='0' border='0' width='25'> <tbody>" If strLinkedIn <> "" Then CreateSigFile.WriteLine "<tr><td style='height:12px; font-size:1px' height='12'> </td></tr> <tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='" & strLinkedIn & "' target='_blank' rel='noopener'><img border='0' width='26' height='25' alt='linkedin icon' style='border:0; height:25px; width:26px;' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/ln.png'></a></td> </tr>" End If If strInstagram <> "" Then CreateSigFile.WriteLine "<tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='" & strInstagram & "' target='_blank' rel='noopener'><img border='0' width='26' height='25' alt='instagram icon' style='border:0; height:25px; width:26px;' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/it.png'></a></td> </tr>" End If If strPinterest <> "" Then CreateSigFile.WriteLine "<tr> <td width='25' height='30' valign='top' style='vertical-align: top;'><a href='" & strPinterest & "' target='_blank' rel='noopener'><img border='0' width='26' height='25' alt='pinterest icon' style='border:0; height:25px; width:26px' src='https://www.mail-signatures.com/signature-generator/img/templates/hexagonal-logo/pt.png'></a></td> </tr>" End If CreateSigFile.WriteLine "</tbody></table>" CreateSigFile.WriteLine "</td>" CreateSigFile.WriteLine "</tr>" CreateSigFile.WriteLine "<tr><td colspan='4' style='padding-top:15px;'> <a href='" & strBannerLinkingTo & "' target='_blank' rel='noopener'><img border='0' alt='Banner' width='479' style='max-width:479px; height:auto; border:0;' src='" & strBanner & "'></a> </td>" CreateSigFile.WriteLine "</tr>" CreateSigFile.WriteLine "<tr><td colspan='4' style='padding-top:15px; line-height:14px; font-size: 7.5pt; color: #808080; font-family: Arial, sans-serif;'>The content of this email is confidential and intended for the recipient specified in message only. It is strictly forbidden to share any part of this message with any third party, without a written consent of the sender. If you received this message by mistake, please reply to this message and follow with its deletion, so that we can ensure such a mistake does not occur in the future.</td>" CreateSigFil CreateSigFile.WriteLine "</tbody>" CreateSigFile.WriteLine "</table>" CreateSigFile.WriteLine "</BODY>" CreateSigFile.WriteLine "</HTML>" CreateSigFile.Close Set objWord = CreateObject("Word.Application") Set objSignatureObjects = objWord.EmailOptions.EmailSignature objSignatureObjects.NewMessageSignature = strUserName & "2" objSignatureObjects.ReplyMessageSignature = strUserName & "2" objWord.Quit
Creating your own script
You can feed any HTML signature to the VBScript. For good examples of HTML signature templates, go to the free email signature generator or the free signature template library.
The general idea for creating your own script with the help of the sample scripts provided in the previous section of this article is to replace the code under the ‘Signature’s HTML code comment with your own. Keep in mind to replace user-specific data with placeholders, for example, use strFullName in place of the user’s name.
If you use the free email signature generator, you can get rid of the global placeholders found in the script above. Simply provide your company’s data as well as all the necessary links and graphics in the generator instead of replacing them with global placeholders in HTML code.
Deploying the script for a single user
Before you run the script for everyone in your company, it’s best to test it for a single user. To deploy the script, whether it’s your custom one or one of the samples provided above, follow these few simple steps:
- Copy & paste the VBScript code into any basic text editor (for example Notepad or Notepad++).
- Replace values for global placeholders (if applicable).
- Save the file with a .vbs extension.
- Run the script by double-clicking the VBS file.
- Finally, go to Outlook > File > Options > Mail > Signatures and confirm whether a signature with the same name as your AD account name has been added to the list of available signatures.
Now, when you get to the signature settings, you might see that the graphics are flattened, like that:
That’s because the Outlook’s signature editor doesn’t parse HTML code very well. The problem comes from the graphics’ height being set to “auto”. Fortunately, when the signature is added into an email, it’s parsed correctly.
Deploying the script for multiple users
There are two simple ways to deploy the script for multiple users. One of them is to launch the VBS file from each workstation, the second is to use GPO and a logon script. Since the first method is self-explanatory, I will show how to deploy the signature using GPO.
- Use the Windows logo key+R key combination to launch the Run console. Type gpmc.msc and press Enter to launch the Group Policy Management Editor.
- In the Editor, go to User Configuration > Policies > Windows Settings > Scripts. Right-click Logon and click Properties from the context menu.
- In the Logon Properties window, click Add.
- In the window that opens, click Browse.
- Locate your VBS file, highlight it, and add it to the logon script by clicking Open.
- Finally, confirm by clicking Apply and OK.
The next time a user logs in, the signature script should run, and the email signature should be added to that user’s Outlook profile.
Professional email signature management
VBScript, together with GPO, lets you manage email signatures across company. Thanks to this method, you can successfully deploy unified email signatures for every Outlook user in your organization. However nice it is, the method isn’t perfect. Here are just some of its drawbacks:
- requires at least basic scripting knowledge,
- doesn’t work with any email client other than desktop Outlook for Windows,
- doesn’t prevent users from changing the signature,
- updates take time (you need to change the script and to redistribute it),
- it’s impossible to delegate this task to a marketing team,
- if for some reason the script won’t work in your environment (e.g., you use non-standard port to communicate with LDAPS), you are on your own when it comes to troubleshooting.
That’s why we came up with tools for email signature management. The CodeTwo Exchange Rules family of products (for Exchange Server versions from 2007 to 2019) and CodeTwo Email Signatures 365 (for Microsoft 365 organizations) take email signature management to a whole different level. These tools let you:
- Design email signatures using a simple WYSIWYG editor or import any HTML code easily.
- Add email signatures to emails send from any email client or device (including mobiles).
- Add different email signature templates for different scenarios (depending on the recipient, different signature for first and subsequent emails in a conversation thread).
- Prevent users from making any changes to the signature or disclaimer.
- Implement changes to signatures instantly (changing images).
- Embed images, so that they are always visible for your recipients (without the need to click “Download pictures”).
- Schedule marketing campaigns.
- Keep calm, knowing you have 24/5 Customer Success Team available, should you run into any issues.
- And benefit from many more features…
Try CodeTwo Email Signatures 365 for free – if you have a Microsoft 365 organization.
Try CodeTwo Exchange Rules for free – if you are running an on-premises Exchange Server.
Dear Adam,
Thanks a million for your excellent article. I’ve used your script and it works like a charm. I had to modify it a little and want to share my update. For GDPR in Europe, UPN are anonymized and email addresses does not match. So signatures were seen as “Signature on your device” and not editable. Changing the name of the signature did the trick :
SigFile = SigFolder & UserObj.sAMAccountName & ” (” & UserObj.UserPrincipalName & “).htm”
Thanks again,
Eric
Thanks a million Eric!
Glad you found the script useful and thanks for the insights on the anonymized UPNs. I didn’t run into this problem, but in case someone else is affected by it, your comment will be there to help.
How could I get this signature to be part of Outlook’s roaming signatures so the signature gets pulled into OWA? It clearly needs the user’s email address in the signature file name, but it clearly needs something else because even if I add that name and it does get added into OWA, there’s nothing in the signature.
Unfortunately, when roaming signatures (signature cloud settings) are turned on, Outlook no longer has connection to the local email signatures, rendering VBScript useless. And when roaming signatures are disabled, signatures won’t be synced to OWA. Theoretically, it could be possible to use VBScripts while the signature cloud settings are turned off and turn them on afterwards, but, as we’ve already mentioned in this article, it often results in unexpected signature problems.
In other words, roaming signatures do not come with a reliable way to manage email signatures company-wide. Learn more
Worked well for me after some modification for my purposes. Thanks so much. It’s people like you that help the rest of us muddle through. My grateful thanks.
Dear Adam.
Thank you with script.
I have trouble with picture, which show as logo and this is show only on sender side.
Just have other script without html code which generate sig, I found that script create htm, rtf, .txt and folder with files. But your script create only htm file. Can you advice how solve problem with images ? I mean show as logo.
Thank you.
%appdata%\Roaming\Microsoft\Signatures
Hi Kamil,
Unfortunately, I won’t be able to fix your script, but feel free to investigate the script from this and previous article, since methods used to add images differ slightly.
When it comes to RTF & TXT signature versions – openinig the signature in the email signature editor generates those alternative versions automatically.
Hi,
We are using this script but find that the line –
Set CreateSigFile = FileSysObj.CreateTextFile (SigFile, True, True)
is returning the error “Path not found”. I’ve confirm the path is correct and when we invoke the script after the user is logged in it works fine.
Is there any possible timing issue or anything else that could cause the path above not to be available at the login time?
I’ve never run into this issue when using a logon script. Do you have any additional scripts added in the Group Policy Management Editor?
Hi,
Thanks for the script. Is it possible to have the mobile number in the signature, but if this is blank on the AD it will skip it?
Hi Liam,
With the current script, when an AD field is empty, no value will be added, but the signature will include a signalling phrase (like “mobile:”).
You can try to overcome this problem with an if… else… statement.
Hi there,
This is a great script, but for some reason im getting an issue on this specific line
Set objUser = GetObject(“LDAP://” & objSysInfo.UserName)
error code = 0x80005000
Please help
Thanks
Chris
Looks like there is a problem connecting with LDAP. I’m afraid I won’t be able to help troubleshoot without any access to the environment which suffers from the problem.
Great tutorial!
Do you know guys if it’s possible to use extensionAttrifbute to vbscript?
Thanks!
The last time I checked, I could get extensionAttributes to work.
Hi When I run script 2 as my standard user account, the script executes fines and completes, however I just get a blank htm file in the %appdata%\Roaming\Microsoft\Signatures direcotry named myfirstname.mylast2.htm. Any suggestions what I am missing?
Hi Anthony,
Can’t be sure what exactly is the problem without seeing the script, but my guess is something went wrong in the ‘Signature’s HTML code part of the script. I’d review information from this section and try again.
Fantastic script, I have managed to modify it for most of my needs, but I do have one question. None-English characters.
I want to put “Mit freundlichen Grüßen – Best Regards” as a header, so put in.
CreateSigFile.WriteLine “”
CreateSigFile.Writeline “Mit freundlichen Grüßen – Best Regards”
But I get out
Mit freundlichen Grüßen – Best Regards
How can I get this to work correctly?
Thanks
Try replacing special characters with HTML entity codes, that is:
change ü to
ü
and ß to
ß
I am using a similar script for our company which has suddenly stopped to work about 3 weeks ago. It gets stuck at objSignatureObject.NewMessageSignature like if the Outlook process is waiting for something. I came here to see if I could find a solution to my problem, but it seems that the code here, at least in Script 1, runs into the same problem. There is also no error, the script just waits as for maybe an input in Outlook. We are using Microsoft Outlook for Microsoft 365 MSO (Version 2110 Build 16.0.14527.20332) 64 Bit. We had the same problem with only one user about 7 month ago which went on for about 2 weeks and then suddenly disappeared again. Does someone has a similar problem and found a solution to it?
Cheers
Chris
You fixed the problem by using the embed feature of a personal OneDrive!!!!
Thank you very Much.
Hello Again,
So I got this thing chugging thoroughly but I am running into a problem and wanted to see if you had any ideas on how to Embed The image Permanently or something when creating the Signature.
When linking to object on my NAS Drives, The signature only populates in office or on the VPN, otherwise it shows the missing picture symbol. If I link it to OneDrive, it populates in the email, but as soon as I hit send they disappear.
Any ideas on how to permanently embed it when creating the signature, or do I just add the extra step of a script that auto copies the files to a Their Base C: Drive and link that way?
Thanks again for your hard work on this script! This saved me hours!
Hi,
Glad I could be of help!
You could use pretty much any image hosting service, as long as you use a direct image URL. Here is a guide on direct links.
I guess adding images to the target signature folder would work, but I have never tested it. I’ll try to give it a go as soon as I get a chance.
Thank you for replying. I found that in my code I assigned a variable
SigFilename="DefaultSignature.htm"
and later
objSignatureObjects.NewMessageSignature = SigFilename
The object.property cannot have an extension and only needs the filename.
The new problem is that this code via logon script does not work if the user has more than one profile. When running outside of the logon process it pops up the profile selection box and the user clicks ok but it does not complete the process. The file exists in the correct directory but the final step of adding the default will not populate.
Does a multiple profile setup require additional programming to identify the profile parameters?
I’m afraid that with multiple Outlook profiles, it becomes too compliacted to handle effectively with VBScript. Feel free to experiment, though.
I have implemented this. It creates the file in the correct spot and is available for selecting it in Outlook but it doesn’t populate the filename in the default signatures as expected. If I cannot get it to work properly from my session I don’t think it will work when pushing it out with a logon script.
I chose this model because all other similar scripts seem to do more with registry entries and impersonation to access the profile which I would like to avoid. Can you tell me if there are limitations?
As long as you make sure that the name of the created HTML signature file (SigFile = SigFolder & UserObj.sAMAccountName & “1.htm”)
Is the same as in the assignment part: (objSignatureObjects.NewMessageSignature = strUserName & “1”)
Everything should work all right. Keep in mind that in those scripts, the signature is named, for example, j.doe1 for the first script.
Amazing! Thank you!
Hi, these are so bloody useful, thanks! I’m using script 1 and it’s formatting beautifully, however it doesn’t appear to be setting as the default for New or Reply messages. Am I missing something?
The
objSignatureObjects.NewMessageSignature = strUserName & "1"
code is responsible for that. It seems I’ve left the & “1” part from testing, so the name of the signature is, for example, j.doe but the script tries to set j.doe1 as the default signature.I’ve fixed it – now the name of the signature includes “1” as well.
Question for you! I got the script working well and modified it for my companies needs, so thank you so much!!
How would I go about getting it to save as RTF and a TXT file as well? no that it matters all that much, but When we create it inside the outlook editor it saves it as those file types as well.
I appreciate your time making this and saving me the heartache!
Best,
Rob
If I remember correctly, the RTF and TXT files are generated automatically, whenever a user opens the signature within the signature editor. Not sure if it’s that important to have all the formats, since the signature can be automatically converted to plain-text format, even without the dedicated version. And I don’t remember the last time I’ve received an email in the RTF format.