Useful Tech Tips, Tutorials and guides

How to Setup Email Signature with logon script

This is a simple how to on ensuring your users email signatures are all standard (Under your Control) its a small vb script that defines variables from the active directory then uses a macro style operation to generate the signature.

Here is the script.


On Error Resume Next

Set objSysInfo = CreateObject(“ADSystemInfo”)

Set WshShell = CreateObject(“WScript.Shell”)

strUser = objSysInfo.UserName
Set objUser = GetObject(“LDAP://” & strUser)

strName = objUser.FirstName & ” ” & objUser.LastName
strTitle = objUser.Description
strCred = objUser.info
strStreet = objUser.StreetAddress
strLocation = objUser.l
strPostCode = objUser.PostalCode
strPhone = objUser.TelephoneNumber
strOtherPhone = objUser.otherTelephone
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail
strPostal = objUser.PostOfficeBox
‘=====================================
‘ Full Signature.
‘=====================================

Set objWord = CreateObject(“Word.Application”)

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Name = “Arial”
objSelection.Font.Size = 10
objSelection.Font.Bold = true
objSelection.TypeText Ucase(strName) & Chr(11)
objSelection.Font.Bold = false
objSelection.Font.Italic = true
objSelection.TypeText strTitle & Chr(11)
objSelection.Font.Italic = false
objSelection.TypeText Chr(11)
objSelection.Font.Bold = true
objSelection.TypeText “Mobile: ”
objSelection.Font.Bold = false
objSelection.TypeText strMobile & Chr(11)
objSelection.Font.Bold = true
objSelection.TypeText “Direct: ”
objSelection.Font.Bold = false
objSelection.TypeText strOtherPhone & Chr(11)
objSelection.Font.Bold = true
objSelection.TypeText “Email: ”
objSelection.Font.Bold = false
objSelection.Hyperlinks.Add objSelection.range, “mailto:” & strEmail, , , strEmail & Chr(11)
objSelection.Font.Bold = true
objSelection.TypeText “Street: ”
objSelection.Font.Bold = false
objSelection.TypeText strStreet & ” ” & strLocation & ” ” & strPostCode & Chr(11)
objSelection.Font.Bold = true
objSelection.TypeText “Postal: ”
objSelection.Font.Bold = false
objSelection.TypeText strPostal & Chr(11)
objSelection.InlineShapes.AddPicture “\serversignature.jpg”
objSelection.TypeText Chr(11)
objSelection.TypeText Chr(11)
objSelection.Font.Size = 7
objSelection.Font.Bold = false
objSelection.Font.Italic = true
objSelection.TypeText “The information contained in this transmission including any attached documentation is privileged and confidential. It is intended only for the use of the individual or entity named above. If the reader of this message is not the intended recipient, you are hereby notified that any dissemination, distribution or copy of this communication is strictly prohibited. If you have received this communication in error, please notify your Administrator immediately by replying to this email. Please delete all copies of this message and any attachments immediately.”
objSelection.TypeText Chr(11)
objSelection.Font.Italic = false
objSelection.Font.Name = “Webdings”
objSelection.Font.Size = “15”
objSelection.Font.Color = RGB(115,155,63)
objSelection.TypeText “P ”
objSelection.Font.Name = “Calibri”
objSelection.Font.Size = “10”
objSelection.TypeText “Please consider the environment before printing this e-mail.”
Set objSelection = objDoc.Range()

objSignatureEntries.Add “Full Signature”, objSelection
objSignatureObject.NewMessageSignature = “Full Signature”

objDoc.Saved = True
objWord.Quit
‘=====================================
‘ Reply Signature
‘=====================================

Set objWord = CreateObject(“Word.Application”)

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection

Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature

Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

objSelection.Font.Name = “Arial”
objSelection.Font.Size = 10
objSelection.Font.Bold = true
objSelection.TypeText Ucase(strName) & Chr(11)
objSelection.Font.Bold = false
objSelection.Font.Italic = true
objSelection.TypeText strTitle & Chr(11)
objSelection.Font.Italic = false
objSelection.TypeText Chr(11)
objSelection.TypeText “Mobile: ” & strMobile & Chr(11)
objSelection.TypeText “Email: ” & strEmail

Set objSelection = objDoc.Range()

objSignatureEntries.Add “Reply Signature”, objSelection

objSignatureObject.ReplyMessageSignature = “Reply Signature”

objDoc.Saved = True
objWord.Quit

——————————————————————————————————————–

The Script its self is pretty rudimentary, Where objects are defined and then “typed” into the signature.
Remember you AD needs to be up to date as all the values are called from the fields in Active Directory. To install and use simply copy and paste the script and paste it into notepad save it as Signature.vbs then add it to your logon script “wscript \serverSYSVOLdomain.localscriptssignature.vbs” or add it to the logon/logoff fields in Group Policies if you need to remove a line simply comment it out with a ‘ that way if you need to use it again you dont have to search the earth for the correct wording.

Here are some of the additions to the script:

Insert another line – Chr(11)
Add an Image to the signature – objSelection.InlineShapes.AddPicture “\serversignature.jpg”
Add Text – objSelection.TypeText “Message footer or Privacy Statement.”