AD Based Outlook Email Signature for 2003 and 2007 Continued – Implementation Guide

earlier on in the year I blogged about AD based signatures for 2003 and 2007 outlook (find the post here), It seems I am not the only person that needs this, I have been getting rather high stats on this topic and a few questions.

So I thought I would go through a little more in detail in terms of what you have to modify and how you would go about implementing the script into an AD based environment.

Ok So lets start with the script and what you need to modify. I will highlight in RED what needs to change

NOTE: DO NOT COPY AND PASTE THE BELOW SCRIPT IT WILL NOT WORK, as there are various comments to show you what you need to change. Please refer to the previous post which has the original code, which you should copy, paste and modify.

 

‘====================

‘ VBScript: <Signatures.vbs>
‘ AUTHOR: Peter Aarts
‘ Contact Info: peter.aarts@l1.nl
‘ Version 2.04
‘ Date: January 20, 2006
‘ Moddified By Brad Marsh Now works with both 2003 and 2007 outlook
‘ Contact: gentex@tpg.com.au
‘ Date 19 feb 08
‘ Tested on Vista, XP, XP64 and office 2003 and 2007.
‘ NOTE will not work that well with various email accounts
‘====================

‘Option Explicit
On Error Resume Next

Dim qQuery, objSysInfo, objuser
Dim FullName, EMail, Title, PhoneNumber, MobileNumber, FaxNumber, OfficeLocation, Department
Dim web_address, FolderLocation, HTMFileString, StreetAddress, Town, State, Company
Dim ZipCode, PostOfficeBox, UserDataPath

‘ Read LDAP(Active Directory) information to asigns the user’s info to variables.
‘====================
Set objSysInfo = CreateObject(“ADSystemInfo”)
objSysInfo.RefreshSchemaCache
qQuery = “LDAP://” & objSysInfo.Username
Set objuser = GetObject(qQuery)

FullName = objuser.displayname
EMail = objuser.mail
Company = objuser.Company
Title = objuser.title
PhoneNumber = objuser.TelephoneNumber
FaxNumber = objuser.FaxNumber
OfficeLocation = objuser.physicalDeliveryOfficeName
StreetAddress = objuser.streetaddress
PostofficeBox = objuser.postofficebox
Department = objUser.Department
ZipCode = objuser.postalcode
Town = objuser.l
MobileNumber = objuser.TelephoneMobile
web_address = http://www.elcom.com.au”  — Change this to your web address

‘ This section creates the signature files names and locations.
‘====================
‘ Corrects Outlook signature folder location. Just to make sure that
‘ Outlook is using the purposed folder defined with variable : FolderLocation
‘ Example is based on Dutch version.
‘ Changing this in a production enviremont might create extra work
‘ all employees are missing their old signatures
‘====================
Dim objShell, RegKey, RegKey07, RegKeyParm
Set objShell = CreateObject(“WScript.Shell”)
RegKey = “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General”
RegKey07 = “HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General”
RegKey07 = RegKey07 & “\Signatures”
RegKey = RegKey & “\Signatures”
objShell.RegWrite RegKey , “AD_elcom” — Change this to what you would like the regitsry key to specify

objShell.RegWrite RegKey07 , “AD_elcom”– Change this to what you would like the regitsry key to specify

UserDataPath = ObjShell.ExpandEnvironmentStrings(“%appdata%”)
FolderLocation = UserDataPath &”\Microsoft\AD_elcom\” – Change this to your desired path
HTMFileString = FolderLocation & “Elcom.htm” — change this to your desired file name

‘ This section disables the change of the signature by the user. AND HAS BEEN COMMENTED OUT, uncommented it at your risk
‘====================
‘objShell.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature” , “L1-Handtekening” — change this to your desired setting (note I did not use these settings they were commented out

‘objShell.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature” , “L1-Handtekening” — change this to your desired setting (note I did not use these settings they were commented out

‘objShell.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging” , “0″, “REG_DWORD”

‘ This section checks if the signature directory exits and if not creates one.
‘====================
Dim objFS1
Set objFS1 = CreateObject(“Scripting.FileSystemObject”)
If (objFS1.FolderExists(FolderLocation)) Then
Else
Call objFS1.CreateFolder(FolderLocation)
End if

‘ The next section builds the signature file
‘====================
Dim objFSO
Dim objFile,afile
Dim aQuote
aQuote = chr(34)

‘ This section builds the HTML file version
‘====================
Set objFSO = CreateObject(“Scripting.FileSystemObject”)

‘ This section deletes to other signatures.
‘ These signatures are automaticly created by Outlook 2003.
‘====================
Set AFile = objFSO.GetFile(Folderlocation&”Elcom.rtf”)
aFile.Delete
Set AFile = objFSO.GetFile(Folderlocation&”Elcom.txt”)
aFile.Delete

Set objFile = objFSO.CreateTextFile(HTMFileString,True)
objFile.Close
Set objFile = objFSO.OpenTextFile(HTMFileString, 2)

 

– HERE WE ARE STARTING HOW THE HTML LOOKS –

NOTES:
always start a new line of code with objfile.write “
Close every line with ” & vbCrLf

the rest is simple HTML, you will need to change this to suite your requirements

–start of HTML  Body Started, you can copy this–

objfile.write “<!DOCTYPE HTML PUBLIC ” & aQuote & “-//W3C//DTD HTML 4.0 Transitional//EN” & aQuote & “>” & vbCrLf
objfile.write “<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>” & vbCrLf
objfile.write “<META http-equiv=Content-Type content=” & aQuote & “text/html; charset=windows-1252″ & aQuote & “>” & vbCrLf
objfile.write “<META content=” & aQuote & “MSHTML 6.00.3790.186″ & aQuote & ” name=GENERATOR></HEAD>” & vbCrLf
objfile.write “<body>” & vbCrLf

– Start of Style and open and close of head, you can copy this you may want to change the style a little –

objfile.write “    <head> <style type=text/css>” & vbCrLf
objfile.write “}” & vbCrLf
objfile.write “.style4 {” & vbCrLf
objfile.write “    text-decoration: none;” & vbCrLf
objfile.write “    color: #696969;” & vbCrLf
objfile.write “    font-family: Verdana;” & vbCrLf
objfile.write “}” & vbCrLf
objfile.write “</style></head>” & vbCrLf

 

–Start of the actual Signature, CHANGE this, however make sure you keep the Variables in tack, just more them to suite you variables in this signature are and should look like below when inserted into the HTML:

“& FullName &”
“& EMail &”
“& Company &”
“& Title &”
“& PhoneNumber &”
“& FaxNumber &
amp;”
“& OfficeLocation &”
“& StreetAddress &”
“& PostofficeBox &”
“& Department &”
“& ZipCode &”
“& Town &”
“& MobileNumber &”
“& web_address &”

I will highlight them red so you can see where they actully are used within the HTML, I did not use all of the variables listed above.

 

 

objfile.write “<font color=696969 face=Verdana>” & vbCrLf
objfile.write “<b> <span style=’font-size: 10pt;’> “& FullName & “</span> </b> ” & vbCrLf
objfile.write “<span style=’color: #FF0000;font-size: 10pt;font-weight: bold;’>|</span> ” & vbCrLf
objfile.write “<a href=mailto:” & Email &” span style=’font-size: 8pt;text-decoration: none;color: #696969;’ > <span style=’font-size: 8pt;text-decoration: none;color: #696969;’>” & Email &” </span></a>” & vbCrLf
objfile.write “<br>” & vbCrLf
objfile.write “<span style=’font-size: 8pt;color: #696969;font-weight: bold;’>” & title & ” </span> <br>” & vbCrLf
objfile.write “<br>” & vbCrLf
objfile.write “<span style=’font-size: 7.5pt;color: #696969;’>“& Company & ” </span>” & vbCrLf
objfile.write “<span style=’color: #FF0000; font-size: 7.5pt;’>|</span> <span style=’font-size: 7.5pt;color: #696969;’>Australian Technology Park</span> ” & vbCrLf
objfile.write “<span style=’color: #FF0000; font-size: 7.5pt;’>| </span> ” & vbCrLf
objfile.write “<span style=’font-size: 7.5pt;color: #696969;’> Sydney </span><br>” & vbCrLf
objfile.write “<span style=’color: #FF0000; font-size: 7.5pt;’>t</span><span style=’font-size: 7.5pt;color: #696969;’> +612 ” & PhoneNumber &”</span><span style=’color: #FF0000; font-size: 7.5pt;’>&nbsp;&nbsp;f</span><span style=’font-size: 7.5pt;color: #696969;’> +612 9209 4423</span>” & vbCrLf
objfile.write “<span style=’color: #FF0000; font-size: 7.5pt;’>| </span>” & vbCrLf
objfile.write “<span style=’font-size: 7.5pt;color: #696969;’> <a href=http://www.elcom.com.au><span class=style4>www.elcom.com.au</a></span> </span><br>” & vbCrLf
objfile.write “<br>” & vbCrLf
objfile.write “<A href=http://www.elcom.com.au/> <img src=http://www.elcom.com.au/images/elcom-logo-web-175×70.gif height=70 width=175 border=0></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;” & vbCrLf
objfile.write “<img src=http://www.elcom.com.au/images/mspartner.jpg height=55 width=265><br>” & vbCrLf
objfile.write “<br>” & vbCrLf
objfile.write “<span style=’font-size: 7.5pt;color: #696969;’>Please consider </span><span style=’font-size: 7.5pt;color: #00b050;’>our environment</span><span style=’font-size: 7.5pt;color: #696969;’> before printing this email.</span></font><font color=696969 size=1 face=Verdana><br> ” & vbCrLf
objfile.write “<hr size=1 font align=left width=465 color=696969><span style=’font-size: 7.5pt;color: #696969;’>This email is intended for the intended recipients(s) and may contain confidential information. <br> Reproduction, dissemination or distribution of this message is prohibited unless authorised by the sender.<br> If you are not the intended recipient, please notify the sender immediately and you must not read,<br> keep, use, disclose, copy or distribute this email without the sender’s prior permission.<br> The views expressed by the sender are not necessarily those of Elcom Technology Pty Ltd</font></span></font>” & vbCrLf

objFile.Close

 

–END OF HTML–

 

‘ ===========================
‘ This section readsout the current Outlook profile and then sets the name of the default Signature
‘ ===========================
‘ Use this version to set all accounts
‘ in the default mail profile
‘ to use a previously created signature

Call SetDefaultSignature(“Elcom“,”")  — this appears in the outlook file as the signature name, change it to desired

‘ Use this version (and comment the other) to
‘ modify a named profile.
‘Call SetDefaultSignature _
‘ (“Signature Name”, “Profile Name”)

Sub SetDefaultSignature(strSigName, strProfile)
Const HKEY_CURRENT_USER = &H80000001
strComputer = “.”

If Not IsOutlookRunning Then
Set objreg = GetObject(“winmgmts:” & _
“{impersonationLevel=impersonate}!\\” & _
strComputer & “\root\default:StdRegProv”)
strKeyPath = “Software\Microsoft\Windows NT\” & _
“CurrentVersion\Windows ” & _
“Messaging Subsystem\Profiles\”
‘ get default profile name if none specified
If strProfile = “” Then
objreg.GetStringValue HKEY_CURRENT_USER, _
strKeyPath, “DefaultProfile”, strProfile
End If
‘ build array from signature name
myArray = StringToByteArray(strSigName, True)
strKeyPath = strKeyPath & strProfile & _
“\9375CFF0413111d3B88A00104B2A6676″
objreg.EnumKey HKEY_CURRENT_USER, strKeyPath, _
arrProfileKeys
For Each subkey In arrProfileKeys
strsubkeypath = strKeyPath & “\” & subkey
objreg.SetBinaryValue HKEY_CURRENT_USER, _
strsubkeypath, “New Signature”, myArray
objreg.SetBinaryValue HKEY_CURRENT_USER, _
strsubkeypath, “Reply-Forward Signature”, myArray
Next
Else
strMsg = “Please shut down Outlook before ” & _
“running this script.” – this is the message when error occurs, change it to desired.


MsgBox strMsg, vbExclamation, “SetDefaultSignature”
End If
End Sub

Function IsOutlookRunning()
strComputer = “.”
strQuery = “Select * from Win32_Process ” & _
“Where Name = ‘Outlook.exe’”
Set objWMIService = GetObject(“winmgmts:” _
& “{impersonationLevel=impersonate}!\\” _
& strComputer & “\root\cimv2″)
Set colProcesses = objWMIService.ExecQuery(strQuery)
For Each objProcess In colProcesses
If UCase(objProcess.Name) = “OUTLOOK.EXE” Then
IsOutlookRunning = True
Else
IsOutlookRunning = False
End If
Next
End Function

Public Function StringToByteArray _
(Data, NeedNullTerminator)
Dim strAll
strAll = StringToHex4(Data)
If NeedNullTerminator Then
strAll = strAll & “0000″
End If
intLen = Len(strAll) \ 2
ReDim arr(intLen – 1)
For i = 1 To Len(strAll) \ 2
arr(i – 1) = CByte _
(“&H” & Mid(strAll, (2 * i) – 1, 2))
Next
StringToByteArray = arr
End Function

Public Function StringToHex4(Data)
‘ Input: normal text
‘ Output: four-character string for each character,
‘ e.g. “3204″ for lower-case Russian B,
‘ “6500″ for ASCII e
‘ Output: correct characters
‘ needs to reverse order of bytes from 0432
Dim strAll
For i = 1 To Len(Data)
‘ get the four-character hex for each character
strChar = Mid(Data, i, 1)
strTemp = Right(“00″ & Hex(AscW(strChar)), 4)
strAll = strAll & Right(strTemp, 2) & Left(strTemp, 2)
Next
StringToHex4 = strAll

End Function

 

Ok that’s the end of the code

Now on to how to implement it into AD.

First this is first, copy your .vbs to one of the domain controllers, We generally put
scripts in the following location (we do this so that the scripts are replicated through our AD servers, if you have multiple AD server I recommend putting it in the same place.

\\computername\SYSVOL\domain name\scripts\

You will need to ensure all your users that you are applying this to have the required fields complemented with in AD remember your variables, these are what you will need filled in (or at least what you use within the signature)

“& FullName &”
“& EMail &”
“& Company &”
“& Title &”
“& PhoneNumber &”
“& FaxNumber &”
“& OfficeLocation &”
“& StreetAddress &”
“& PostofficeBox &”
“& Department &”
“& ZipCode &”
“& Town &”
“& MobileNumber &”
“& web_address &”

 

Now you to the users that you are applying this script to you must have a GROUP POLICY that is applied to those users, if not create one, or just use the default domain policy.

open up that group policy you wish to apply this VBS to and then within the Group Policy Editor choose:

User configuration
  Windows Settings
      Scripts (logon/logoff)
          Logon

double click on logon, you will see the below screen, you may not have anything in it just yet though, to add the location go to ‘Add’ and then simply browse to the location of the VBS. I am using a logon.bat because we have various logon scripts we execute, so we have complied it into just the one batch file that opens and executes all scripts.

image

 

Once you have added the file press OK.

That’s more or less all you need to do, however you might want to test it to do this you may want to force the GP to refresh

at the command line type ‘gpupdate /force’

then log off and then on, open outlook and test.

 

For any 2007 users if you find that after you run the script and then you or a user opens outlook after login and they revive the error message that from teh script saying that outlook is open, well there is a way around that too.

Go to your Group Policy management again

this time go to

User configuration
  Administrative Templates
      System/Scripts
          Run logo Scripts Scnchronously

Enable this!

image

 

If you are unsure about this, below is the description of what it is you are enabling

 

image

 

Hopefully this helps a few more people.

Good luck!


85 Responses to “AD Based Outlook Email Signature for 2003 and 2007 Continued – Implementation Guide”

  • AD Based Outlook Email Signature for 2003 and 2007 « Brad Marsh’s Weblog Says:

    [...] NOTE: I have now posted a how to implement article on this topic find it here [...]

  • Derrick Says:

    hi brad, thank you for the effort of sharing this modified script, however i have an error, you cna find it here during the logon process, the error is this

    http://i19.photobucket.com/albums/b164/doswald/Others/scripterror.jpg

    my complete file OutlookSignature.vbs code can be found here:

    http://rapidshare.com/files/114782330/create_a_outlook_signature_based_on_ad_information_tib.vbs.html

    hope u could help me.

    thanks in advance

  • bradmarsh Says:

    ok it should work now
    download the file

    http://rapidshare.com/files/114794412/Signature_fix.vbs.html

    and just run the vbs and if it errors let me know. if nothing happens then it would have run. ( see you used the one that I used on teh other post, which i havent commented anything out so it will not work unless you take all the comments out,I wil fix this post up for future referance)
    and open outlook and you should have a signature.
    If its not working let me know email directly.
    Thanks
    Brad

  • Derrick Says:

    Hi Brad,

    You’re the man! Thanks a lot, I’m now revising it according to the company’s info.

    Thanks mate, big help.

    Regards

  • George Says:

    Hi Brad,

    Congratulations on a great work!

    I am now seriously considering of implementing this code into my domain.

    However, since I have absolutely no idea concerning scripting, I have a question.

    What if I just want my users to maintain their personal signatures, and add one or two lines of code into the HTML of the signature.

    For example, add an image and a disclaimer (i do not have exchange). Can that be done by scripting?

    This just came to me as it seems easier that maintaining an up-to-date AD concerning user details. I will research on this thought by my own, however hour help would be much appreciated.

    Thank you in advance.

  • bradmarsh Says:

    Hi George,

    I know what your saying with personal signaturs, but being that all singatures are stored on the local PC, it would very hard to do this.
    the idead of this signature is simple to enforce a company standard.
    Unfortunatly I know now way that you can change different indivual signatures, that would be extreamly hard I would think.
    However you dont need an exchange server to implement this just Outlook and AD thats it.
    Thanks for your kind comments.
    Brad

  • AD Based Outlook Email Signature for 2003 and 2007 Part 3 - Removing the Reply / forward signature « Brad Marsh’s Weblog Says:

    [...] it you can re-run the above script, of course modify the HTML and other parts to suite you (see here how to change the script)and you should have only signatures on a new message [...]

  • Peter Says:

    Hi Brad, this script looks fine, but isn’t it possibel to work with embedded images (logo) i see you used a link to your website ?

  • Peter Says:

    Brad, the script does create a signature file and does delete the otehr signature files but it doesn’t place the new one as default ???

    ‘====================

    ‘ VBScript:

    ‘ Automatically Creates the default outlook signature

    ‘====================

    ‘Option Explicit
    On Error Resume Next

    Dim qQuery, objSysInfo, objuser
    Dim FullName, EMail, Title, PhoneNumber, MobileNumber, FaxNumber, OfficeLocation, Department, Activity
    Dim web_address, FolderLocation, HTMFileString, StreetAddress, Town, State, Company, Country
    Dim ZipCode, PostOfficeBox, UserDataPath,UserDataPath11,FolderLocation11,HTMFileString11
    Dim CentralTelNumber, CentralFaxNumber
    Dim LineBottom1
    Dim LineBottom2

    ‘ Read LDAP(Active Directory) information to asigns the user’s info to variables.
    ‘====================
    Set objSysInfo = CreateObject(“ADSystemInfo”)
    objSysInfo.RefreshSchemaCache
    qQuery = “LDAP://” & objSysInfo.Username
    Set objuser = GetObject(qQuery)

    FullName = objuser.displayname
    EMail = LCase(objuser.mail)
    Company = objuser.Company
    Title = objuser.title
    PhoneNumber = objuser.TelephoneNumber
    FaxNumber = objuser.FaxNumber
    OfficeLocation = objuser.physicalDeliveryOfficeName
    StreetAddress = objuser.streetaddress
    PostofficeBox = objuser.postofficebox
    Department = objUser.Department
    Activity = objuser.extensionAttribute1
    ZipCode = objuser.postalcode
    Town = objuser.l
    Country = objuser.co
    MobileNumber = objuser.TelephoneMobile
    web_address = “http://www.temco-europe.be”
    CentralTelNumber = objuser.HomePhone
    CentralFaxNumber = objuser.Pager
    LineBottom1 = objuser.extensionAttribute2
    LineBottom2 = objuser.extensionAttribute3

    ‘ This section creates the signature files names and locations.
    ‘====================
    ‘ Corrects Outlook signature folder location. Just to make sure that
    ‘ Outlook is using the purposed folder defined with variable : FolderLocation
    ‘ Example is based on Dutch version.
    ‘ Changing this in a production enviremont might create extra work
    ‘ all employees are missing their old signatures
    ‘====================
    Dim objShell, RegKey, Regkey07, RegKeyParm
    Set objShell = CreateObject(“WScript.Shell”)
    RegKey “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General”
    RegKey07 = “HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\General”
    RegKey = RegKey & “\Signatures”
    RegKey07 = RegKey07 & “\Signatures”
    objShell.RegWrite RegKey , “ADSignature”
    objShell.RegWrite RegKey07 , “ADSignature”
    UserDataPath = ObjShell.ExpandEnvironmentStrings(“%appdata%”)
    FolderLocation = UserDataPath &”\Microsoft\TS\”
    HTMFileString = FolderLocation & “ADSignature.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” , “ad signature”
    ‘objShell.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\ReplySignature” , “ad signature”
    ‘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”

    ‘objShell11.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature” , “ad signature”
    ‘objShell11.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature” , “ad signature”
    ‘objShell11.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging” , “0″, “REG_DWORD”
    ‘objShell11.RegWrite “HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EditorPreference” , “131072″ , “REG_DWORD”

    ‘ This section checks if the signature directory exist and if not creates one.
    ‘====================
    Dim objFS1
    Set objFS1 = CreateObject(“Scripting.FileSystemObject”)
    If (objFS1.FolderExists(FolderLocation)) Then
    Else
    Call objFS1.CreateFolder(FolderLocation)
    End if

    ‘ The next section builds the signature file
    ‘====================
    Dim objFSO
    Dim objFile,afile
    Dim aQuote
    aQuote = chr(34)

    ‘ This section builds the HTML file version
    ‘====================
    Set objFSO = CreateObject(“Scripting.FileSystemObject”)

    ‘ This section deletes two other signatures.
    ‘ These signatures are automaticly created by Outlook 2003.
    ‘====================
    Set AFile = objFSO.GetFile(Folderlocation&”adsignature.rtf”)
    aFile.Delete
    Set AFile = objFSO.GetFile(Folderlocation&”adsignature.txt”)
    aFile.Delete

    Set objFile = objFSO.CreateTextFile(HTMFileString,True)
    objFile.Close
    Set objFile = objFSO.OpenTextFile(HTMFileString, 2)

    objfile.write “” & vbCrLf
    objfile.write “Microsoft Office Outlook Signature” & vbCrLf
    objfile.write “” & vbCrLf
    objfile.write “” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” ” & FullName & “ ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” ” & Title & “” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & Company & “ ” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” &nbsp ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” tel : ” & PhoneNumber & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & Postofficebox & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” fax : ” & FaxNumber & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & StreetAddress & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” mob : ” & MobileNumber & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & Zipcode & ” ” & country & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” ” & EMail & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & web_address & “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write ” ” & vbCrLf
    objFile.Write “” & vbCrLf
    objFile.Write vbCrLf
    objFile.Write “” & vbCrLf

    ‘ ===========================
    ‘ This section readsout the current Outlook profile and then sets the name of the default Signature
    ‘ ===========================
    ‘ Use this version to set all accounts
    ‘ in the default mail profile
    ‘ to use a previously created signature

    Call SetDefaultSignature(“adsignature”,”")

    ‘ Use this version (and comment the other) to
    ‘ modify a named profile.
    ‘Call SetDefaultSignature _
    ‘ (“Signature Name”, “Profile Name”)

    Sub SetDefaultSignature(strSigName, strProfile)
    Const HKEY_CURRENT_USER = &H80000001
    strComputer = “.”

    If Not IsOutlookRunning Then
    Set objreg = GetObject(“winmgmts:” & _
    “{impersonationLevel=impersonate}!\\” & _
    strComputer & “\root\default:StdRegProv”)
    strKeyPath = “Software\Microsoft\Windows NT\” & _
    “CurrentVersion\Windows ” & _
    “Messaging Subsystem\Profiles\”
    ‘ get default profile name if none specified
    If strProfile = “” Then
    objreg.GetStringValue HKEY_CURRENT_USER, _
    strKeyPath, “DefaultProfile”, strProfile
    End If
    ‘ build array from signature name
    myArray = StringToByteArray(strSigName, true)
    strKeyPath = strKeyPath & strProfile & _
    “\9375CFF0413111d3B88A00104B2A6676″
    objreg.EnumKey HKEY_CURRENT_USER, strKeyPath, _
    arrProfileKeys
    For Each subkey In arrProfileKeys
    strsubkeypath = strKeyPath & “\” & subkey
    objreg.SetBinaryValue HKEY_CURRENT_USER, _
    strsubkeypath, “New Signature”, myArray
    objreg.SetBinaryValue HKEY_CURRENT_USER, _
    strsubkeypath, “Reply-Forward Signature”, myArray
    Next
    Else
    strMsg = “Please shut down Outlook before ” & _
    “running this script.”
    MsgBox strMsg, vbExclamation, “SetDefaultSignature”
    End If
    End Sub

    Function IsOutlookRunning()
    strComputer = “.”
    strQuery = “Select * from Win32_Process ” & _
    “Where Name = ‘Outlook.exe’”
    Set objWMIService = GetObject(“winmgmts:” _
    & “{impersonationLevel=impersonate}!\\” _
    & strComputer & “\root\cimv2″)
    Set colProcesses = objWMIService.ExecQuery(strQuery)
    For Each objProcess In colProcesses
    If UCase(objProcess.Name) = “OUTLOOK.EXE” Then
    IsOutlookRunning = True
    Else
    IsOutlookRunning = False
    End If
    Next
    End Function

    Public Function StringToByteArray _
    (Data, NeedNullTerminator)
    Dim strAll
    strAll = StringToHex4(Data)
    If NeedNullTerminator Then
    strAll = strAll & “0000″
    End If
    intLen = Len(strAll) \ 2
    ReDim arr(intLen – 1)
    For i = 1 To intLen(strAll) \ 2
    arr(i – 1) = CByte _
    (“&H” & Mid(strAll, (2 * i) – 1, 2))
    Next
    StringToByteArray = arr
    End Function

    Public Function StringToHex4(Data)
    ‘ Input: normal text
    ‘ Output: four-character string for each character,
    ‘ e.g. “3204″ for lower-case Russian B,
    ‘ “6500″ for ASCII e
    ‘ Output: correct characters
    ‘ needs to reverse order of bytes from 0432
    Dim strAll
    For i = 1 To Len(Data)
    ‘ get the four-character hex for each character
    strChar = Mid(Data, i, 1)
    strTemp = Right(“00″ & Hex(AscW(strChar)), 4)
    strAll = strAll & Right(strTemp, 2) & Left(strTemp, 2)
    Next
    StringToHex4 = strAll
    End Function

  • bradmarsh Says:

    Hi Peter, do you mean embed by img src??

    If so then yes of course you can do this but the the user may not see this, because you would be embeding an image that you see locally.

    Hope this helps

  • bradmarsh Says:

    Hi peter DO NOT USE this above script (it has comments that will cause you errors) I have simply hilighted the points that you need to change use the script that I first supplied on the first AD outlook post, and hen go through this post and then change the hilighted points then you cant go wrong.

    Cheers

    Brad

  • Toby Says:

    Fantastic! This was exactly what was needed. Same ‘basic’ editing of the script and WALLA!
    Moving this further along, can this method be applied for OWA? I am doing some further checking on this and haven’t found anything yet but if you know something that could assist..?
    Thanks Again! Great work.

  • Aaron Says:

    Thanks so much for this, works beautifully and easily customisable for my purposes. Exactly what I have been looking for. This will give us a bit of control over our email signatures.

    This is a far better solution than tagging the email as it goes through the SMTP server. At least this way the users can see the signature in their email when they are typing it up.

    Cheers.

  • Haiko Says:

    Great script! But i still have a question..
    Is it possible for this script to create a “reply signature” as wel?

  • bradmarsh Says:

    hey there, yes it does reply and forward if you read the 3rd post on this it will go through this in more detail, ut pay attention to this line

    strsubkeypath, “Reply-Forward Signature”, myArray

  • Peter van Staden Says:

    Is there a way to make the signature the default replies/forwards signature and new messages signature. ?
    i read the above with regards to
    strsubkeypath, “Reply-Forward Signature”, myArray

    is it not a registry entry ? ir do i change the myArry to my signature name ?

  • bradmarsh Says:

    Hi Peter, use the first script
    http://bradmarsh.wordpress.com/2008/02/18/ad-based-outlook-email-signature-for-2003-and-2007/

    this will give you both forward/reply and new message by default.

    and it does write a registry entry if you see the below:

    objreg.SetBinaryValue HKEY_CURRENT_USER, _
    strsubkeypath, “Reply-Forward Signature”, myArray

    taking note of ’strsubkeypath’ this is declared a little above
    here is the declration:
    ’strsubkeypath = strKeyPath & “\” & subkey’

    Hope this helps :)

  • Derrick Says:

    Hi Brad,

    Me again. I am using your work, Great! Just a question, are there any chances of changing the font type? For example I will use Arial instead of Verdana and its size, can I change it? I tried but can’t.

    I am also looking for way to embed an image little icon because I will use this phrase “Please consider our environment before printing this em-mail.” at the bottom.” When I use the URL address of the image, those users that has no internet access can’t see the image.

    Can you help me please.

    Thanks mate.

  • bradmarsh Says:

    Hi Derrick,

    for the fonts easy – as you can see in my code I am using font attributes with a Span tag, just add your font face you want.

    |

    As for the embed images, I would say go and have alook around on some HTML forums and see what you can do, I am sure its possible, after all its just HTML.

  • Mike Greaves Says:

    Hi Brad

    All good work… just the ticket …

    I’ve been searching for a solution to the plain text vs html side of things

    Is there a way to force outlook to always reply in html format, this keeps it all consistent. I understand everyones opinion on replying in the original format but but but … the boss wants his html

    Any ideas?

  • bradmarsh Says:

    Hi Mike,

    thats a great question, and to be honest, I don’t if we can set the reply as a default HTML as a reply value if the original email was a text format, simply because people will send in a text format, so outlook will use that same format to reply.
    But you can in outlook set all composed messages to use HTML in tools > options > Mail format
    but I am sure you knew that.

    Brad

  • Mike Greaves Says:

    Hi Brad

    Thanks for your input, I’ve since researched that Microsoft make that desicion – cheers Bill.

    This software is available though, appears to work but it’s not a network app so I need 300 licences – nice

    http://www.emailaddressmanager.com/outlook-bells.html

  • bradmarsh Says:

    ouch 300 x $29, there has to be a better way, if you find it be sure to let me know :)

  • Brad Says:

    Thanks for the reply Mike. I decided to pass on the app.
    Instead, I just added code to create a new plain text signature and then set the mail format to be HTML via group policy. By setting all email to be HTML, this should prevent staff from sending rich text by default (I hope).

  • Bruno Says:

    Hi! First thanks for the article, great script that I will probably implement in our company. I’ve got a little issue though that I’m not sure where it’s from. Everything works fine with the script and the local policy, but if I open the Mail Format tab in the Outlook options, the next time I create a new message or reply, the signature is gone. Do you know if this would be a script or policy issue?
    Thanks!
    Bruno

  • bradmarsh Says:

    Bruno, good to hear your using the script, what your telling me sounds nothing like a policy issue as it is applied, so therefor cant be policy. Script well it shouldnt be either. I would start looking at the registy and the system files created
    HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Signatures (2007 outlook)
    or
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General\signatures (2003 outlook)
    Make sure these are created you can see new signature and also reply-forward within the registry, and the path to the location of the html file.
    also look in the path
    %appdata%\Microsoft\yourfoldernamehere\
    and see if the htm files exsit.
    If they dont then for what ever reason they are not being craeted or being deleted by a third party appliaction?
    Let me know how you go
    Brad
    also ensure that

  • Simple Says:

    Hello,

    Many thanks for this very useful information! I am working with Outlook XP, the script works so far, but it doesn’t create a .rtf and .txt file.. So replying on a plain-text e-mail gives an error.

    Can anybody help me with that? Thanks!

  • Snam Says:

    Excellent solution for signatures.

    Regarding reply signatures. I have tried to figure out making different reply signatures and cannot figure out how to do it – Is it possible with this script to make different reply/forward signatures?

  • bradmarsh Says:

    Sure why not have 2 of these scripts being they are controlled by a group policy there is no limit to what you can do you could have one for each dpt if required, for you needs you need to pull out the registry stuff that relates to the new mail message and keep the reply/forward.

    make sure you name the .htm, rtf and txt file different to the first one, might be even better if you put it in a new folder.

    Enjoy.

  • Snam Says:

    Hi again,

    Seems when i reply to an email with clear text my reply signature becomes text only.

    Problem is when I after having replied to a text mail, my primary signature for new messages is NONE.
    Do you have any suggestion to why this might be so?

    Regards

  • Geoff Says:

    Thanks for publishing this. It’s a great solution. FWIW to those who may be interested, the lines used to prevent users from changing the signature is specific to Outlook 2003 as written, but can be easily adjusted to work with Outlook 2007 by changing “11.0″ to “12.0″.

  • Christian Says:

    test

  • Christian Says:

    This script is very good. I will use it, but need to change the signature to my own; I have tried this for hours but can’t make it: Can someone help me with this signature design and make it into the vbs script; look at this signature design:

    http://www.bergersenweb.com/outlooksignature.html

  • Christian Says:

    Nobody?

  • bradmarsh Says:

    Christian, where are you stuck?? what is happening, I would rather not do it because if I do, do it you can be sure there will be others asking the same. Lets work through this!

  • Christian Says:

    hehe, I understand. If you look at the HTML-code for the signature design, yo will see a real mess, and her is my problem, I don’t know how to implent the VB codes in the code mess. I have tried but ends up with an error. Sorry my english, you can correct me.

  • bradmarsh Says:

    Your English is perfectly fine :)
    Where can I find your code?
    did you want to email it to me or post it to me so I can have a look please?
    Thanks

    Brad

  • Christian Says:

    Thanks, the code is to loong, sow wordpress wont let me post it. What Is your email ?

  • Christian Says:

    Hello.

    This script is very nice, I love it.
    But I also use this script on a Terminal Server, users that logs on get the “Outlook is open error” when other users is using Outlook. Whatt???+ Is there a way around this trouble?

  • AD Based Outlook Email Signature for 2003 and 2007 Continued - Implementation Guide - MOVED « Brad Marsh’s Weblog Says:

    [...] - MOVED Posted by bradmarsh under Microsoft, Software, Techie   This post has moved to: http://bradmarsh.net/index.php/2008/05/14/ad-based-outlook-email-signature-for-2003-and-2007-continu... Possibly related posts: (automatically generated)AD Based Outlook Email Signature for 2003 and 2007 [...]

  • Andreas Says:

    Hi
    Great Script, thank you!
    Is this working or customizable for Rich-text Signatures?
    Thanks

  • Brad Marsh Says:

    sure does work with RTF, check out my later posts on this, there was one only very recently.

    http://bradmarsh.net/index.php/2008/11/20/ad-based-outlook-email-signature-for-2003-and-2007-part-4-now-writes-txt-and-rtf-as-well-as-html/

  • biff Says:

    Thank you for all the hard work on this. The amount of time you spent is truly appreciated. This has been one of the most useful posts I have ever encountered on the blogosphere and for that you are a good man.

    I have implemented this at my company and it works perfectly I changed up the HTML of course and my marketing team was pleased but with the beginnings of this script it is just remarkably easy to edit and make it your own.

    Thanks again!

  • Brad Marsh Says:

    thanks for the praise very much appreciated.

    just glad the script helped you out
    brad

  • Shayne Says:

    Love the script, I am a VB idiot and even I got it working.
    I have one request if I may ask.

    Can you show me how to change the reply signature to None in the script?

  • Brad Marsh Says:

    Hi Shayne,

    easy just read on there are quite a few parts to this post due to popular demand.

    see:
    http://bradmarsh.net/index.php/2008/05/21/ad-based-outlook-email-signature-for-2003-and-2007-part-3-removing-the-reply-forward-signature/

    Thanks
    Brad

  • Brodie Says:

    Hi Brad,

    Excellent Script, We’ve been using a word vbs system here, and I hated it, it would log on and lock up word, and play all sorts of nasty tricks.

    However, We were using that because I couldn’t figure a way to have multiple signatures from a htm system.

    I’ve got your script to run as a logon element, and in a loop, such that all the htm’s are generated, with different names, in the same folder, but I can’t figure how to register the htms as signatures.

    Any hints?

    I need it for my Directors who need to be able to sign off emails as various divisions.

    Thanks in Advance!

    –brodie

  • John Taylor Says:

    Great blog. Do you know of any relevant marketing forums or discussion groups?

  • David Says:

    I see in the script that it reserves space for a variable “State”, but there is no variable setting within the script that populates the variable for use. What is the “objuser.” setting that I need to use?

  • Brad Marsh Says:

    There are various variables that have been declared that are not used, I have done this to help any one that needs to use these.

    objusr is a variable is not declared inmy script, it is someone elses

  • travelaffiliateprogramaholic Says:

    This is really a good post so that even though I do not post on blogs, I have to post this time.

  • Daniel Says:

    Hi,

    Firstly I think this is a great script! And it is just what I need to manage my end users signatures.

    However I do have one problem. As soon as I change AD_Elcom to AD_mycompany or when I change elcom.htm to mycompany.htm the script doesn’t work mycompany.htm is created in the ad_mycompany folder, but when I go into Outlook and click new message nothing appears :(

  • Brad Marsh Says:

    Hi there Dan,

    check your registry and ensure its created the entry.
    HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\General”
    Ensure in this location you can see you Signature name? if not then its not creating it in the registry therefore Outlook cant see the file, that should get you off to a good start.
    Brad

  • Daniel Says:

    Oh OK, well it does set the registry entry but it doesn’t automatically set it as the default signature. If I go Tools-Options-mail options-signatures I can see it but I just have to manually select it. I must have deleted part of the script that sets it to the default signature when composing a new message. Thanks for getting back to me

  • Daniel Says:

    I’ve managed to configure it. Basically I have no idea why but I started with the script you originally posted and just replaced Elcom with my company name and then modified the HTML and now it works! :)

  • Michael McKeever Says:

    Brad, I think I have modified your script correctly to display the info for my company but I was wondering if you could take a look at it before I implement it. Let me know the easiest way to upload the script to you.

    Thanks

    Michael

  • Brad Marsh Says:

    Email Sent.

  • Craig Says:

    Thank you so much for sharing this. It looks like something that I am looking to implement. I was wondering, how would this work utilizing Thunderbird as a mail client?

  • Brad Marsh Says:

    Hi Craig, this is specifically written for outlook mail clients, so its not going to work on the thunderbird client, sorry.

  • Craig Says:

    Hi Brad, what I was thinking was by changing the paths from …\Microsoft\Office\…. to the related paths for Thunderbird could this possibly be adapted? Or, is there something else that I’m missing?

  • Johan Says:

    Is it working on terminal server 2003 and 2008?

  • Johan Says:

    It works…
    But i get a error message when i log on.
    “Please shut down outlook before running this script” Is there a solution??

  • Brad Marsh Says:

    Johan, I am assuming your loading outlook on login also… If this is the case then this is why your getting the error, you would have to run the script first and ensure it has run before outlook opens.

    Brad

  • Johan Says:

    Hi,
    The scrip is looking for the process outlook.exe and it’s a terminal server so th process always running there. But i changed the outlook.exe to xxxxx.exe and the problem was solved. Everythign is working fine now, but will there be other problems if a do this?

    And thanks for a mighty script!

  • Chris Says:

    Any solution to the terminal server issue?

  • John S Says:

    Brad

    Does the end user need to be an administrator on the workstation?? I ask because I have your script working on my workstation (I am local admin) but when I test on a non-admin – nothing happens, not even a error

  • Brad Marsh Says:

    Hi Chris,
    Sorry nothing that I know of, apart from some group policies on your server, or adding a script within the startup.

  • Brad Marsh Says:

    Hi John,

    See email response.
    Regards,
    Brad

  • peter Says:

    anyone already got this running for Office 2K10,
    looks like there have been some changes

  • AD Based Outlook Email Signature for 2003, 2007 and NOW 2010!!! | Brad Marsh's Weblog Says:

    [...] here is the full script: (I also suggest before posting any questions you might have refer to the implementation guide posted some time [...]

  • Richard Taylor Says:

    Does anyone know how to get this to work on Windows 7? The script doesn’t even appear to be running, as it’s not complaining that Outlook is already open.

  • Brad Marsh Says:

    Richard,
    The company that I work for runs a mix of XP Vista but PRIMARLY window 7 and it works perfectly… if it is complaining it open I would suggest you open up task a manager and make sure outlook.exe is not within your task manager still before running the script!

  • Ole Eivind Parken Says:

    Hi, i having trouble with the:

    Set objreg = GetObject(“winmgmts:” & _

    “{impersonationLevel=Identify}!\\” & _

    strComputer & “\root\default:StdRegProv”)

    When i logon i get there was a problem in line X and character X…. I have googled a bit but i cant find any1 with this problem, or what that is making the problem… I havent done much programing to any help would be nice.

  • Brad Marsh Says:

    I need some more info… Whats the charter and line number it is talking about? What OS and outlook client are you using?

  • Ole Eivind Parken Says:

    Line 279
    Set objreg = GetObject(“winmgmts:” & _

    “{impersonationLevel=Identify}!\\” & _

    strComputer & “\root\default:StdRegProv”)

    I am using outlook 2010 and windows7
    But in our company we are using windowsXP and newer,
    and the same about outlook, 2003 and newer.

  • Ole Eivind Parken Says:

    sorry about last post, here is an update,
    Line 279
    Set objreg = GetObject(“winmgmts:” & _
    (this is line 279)
    “{impersonationLevel=Identify}!\\” & _

    strComputer & “\root\default:StdRegProv”)

    I am using outlook 2010 and windows7
    But in our company we are using windowsXP and newer,
    and the same about outlook, 2003 and newer
    I tryed now to log on with this policy activ and got the following error message:
    “Windows script host”
    “Script:—\emailsign.vbs”
    “Line:279″
    “Char: 1″
    “Code: 800A03EA”
    “Source: Microsoft VBScript compilationerror”

    Do you know why this error message comes?

  • Ole Eivind Parken Says:

    Problem solved,
    It was just the space between?

    My new problem now is that the outlook dont choose the signature .htm file as default? it removes all other signatures.

  • Ole Eivind Parken Says:

    I solved all the problems. This is a script is genius!

  • Mark Behrendt Says:

    This script is great. I’m working on implementing it, but need to make a minor tweak. How would I have it generate multiple signature files?

    I was looking for a section to copy/paste and modify it to use as my secondary signature, but it seems there are several references across the script.

    Any help would be appreciated.

  • Kieran Pearce Says:

    Hi, i’ve just started testing this script for my network and it works great! However, I’m a little rusty with HTML and haven’t really used VBS before at all!

    Im just editing the HTML part now and trying to add a table. Everytime i add a table and try to run the script i’m getting a “Error: Expected end of statement” error from “Source: Microsoft VBScript compilation error” and its always from the line i’ve just edited.

    The code currenty looks like this:

    //objfile.write “& vbCrLf

    100

    ” & vbCrLf//

    But ive also tried it with objfile.write at the start of every line, with & vbCrLf at the end of every line AND trying put put the whole code, with my content in one long line.

    Can you see anything I’m doing wrong?

    Thanks in advance,
    Kieran

  • Kieran Pearce Says:

    Hi Everyone,
    After a lot of Googleing i managed to sort most of my problems (including the one i posted this morning!) but i have 2 issues which i cant seem to resolve…

    I need to set a background to one area of text but can’t figure out how, and i need to add an image on have it aligned to the right of the text but cant find any options for it. Can anyone confirm if these are possible? and if possible provide some code for me to have a play with?

    Thanks,
    Kieran

  • Brad Marsh Says:

    Anything is possible… Set your style above and set it to a background image that ought to work, you can also set it in a div and float it right.

  • Kieran Pearce Says:

    Thanks for the help Brad,

    I’ve got my signature(s) sorted now, however, has anyone in the comments above had any luck getting 2 signatures to run together? Preferably without setting anything as the default.

  • Kieran Pearce Says:

    Hi guys, i’ve got one last question before i’m completely done setting up my signature! =D

    I need to put a line in to seperate some text (an actual line, not a line break) and am having issues!

    I’ve tried using an hr tag inside a table which worked, except it always made it the whole length of the screen instead of the length i wanted and i’ve tried making the top border of my table black but that didnt work at all!

    Does anyone have any advice?

  • Web Design California Says:

    Web Design CA…

    AD Based Outlook Email Signature for 2003 and 2007 Continued – Implementation Guide | Brad Marsh’s Weblog…

Leave a Reply