Automatically create signature for Outlook 2003/2007/2010 users

Here is a script that you can put into a file such as “signature.vbs” which will allow users to create a signature automatically. You will need to create a template file called sourcesig.htm with placeholders like %USERNAME% inside, and then put these files on a website folder where your users can access it.

In this example, when the user runs the file they are prompted with pop-ups asking for name, telephone etc and then this is written into a signature htm file, along with a pre-made graphic. The user may need to initially select the signature in Outlook, Options after running the script.

Contents of signature.vbs:-

Set objFSO = CreateObject(“Scripting.FileSystemObject”)
Set objShell = CreateObject(“Wscript.Shell”)
Set objNetwork = CreateObject(“Wscript.Network”)
Set objOutlook = CreateObject(“outlook.application”)
strOutl = left(objOutlook.version,2)
strName = objNetwork.UserName
if strOutl < 12 then
strOutl = 2003
elseif strOutl < 13 then
strOutl = 2007
elseif strOutl < 15 then
strOutl = 2010
end if
strVers=InputBox(“Enter Outlook Version”,”Outlook Version”,strOutl)
strArea=InputBox(“Enter Area (HQ, MID or NORTH)”,”Area”,”HQ”)
strName=InputBox(“Enter First and Last Name”,”First and Last Name”,strName)
strJobT=InputBox(“Enter Job Title”,”Job Title”,”Service Manager”)
strMobi=InputBox(“Enter Mobile Number”,”Mobile Number”,”07xxxxxxxxx”)
strEmai=InputBox(“Enter Email”,”Email”,”[email protected]”)
strSigFilePath = objShell.SpecialFolders(“Desktop”)
if strVers = 2003 then strSigFilePath = Replace(strSigFilePath, “Desktop”, “Application Data\\Microsoft\\Signatures\\”)
if strVers = 2007 then strSigFilePath = Replace(strSigFilePath, “Desktop”, “AppData\\Roaming\\Microsoft\\Signatures\\”)
if strVers = 2010 then strSigFilePath = Replace(strSigFilePath, “Desktop”, “AppData\\Roaming\\Microsoft\\Signatures\\”)

myURL1 = “http://xxxxx.co.uk/signatures/sourcesig.htm”
strFile1 = strSigFilePath & “\\sourcesig.htm”
Set objFile = objFSO.CreateTextFile(strFile1,True)
Set objHTTP = CreateObject( “WinHttp.WinHttpRequest.5.1” )
objHTTP.Open “GET”, myURL1, False
objHTTP.Send
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next

myURL2 = “http://xxxxx.co.uk/signatures/” & strArea & “.gif”
strFile2 = strSigFilePath & “\\” & strArea & “.gif”
Set objFile = objFSO.CreateTextFile(strFile2,True)
Set objHTTP = CreateObject( “WinHttp.WinHttpRequest.5.1” )
objHTTP.Open “GET”, myURL2, False
objHTTP.Send
For i = 1 To LenB( objHTTP.ResponseBody )
objFile.Write Chr( AscB( MidB( objHTTP.ResponseBody, i, 1 ) ) )
Next

Set objHTMLSourceFile = objFSO.OpenTextFile(strFile1)
Set objSignatureFile = objFSO.CreateTextFile(strSigFilePath & “xxxxx.htm”)
intLineCount = 1
While Not objHTMLSourceFile.AtEndOfStream
strBuffer = objHTMLSourceFile.ReadLine
strBuffer = Replace(strBuffer, “%USERNAME%”, strName)
strBuffer = Replace(strBuffer, “%JOBTITLE%”, strJobT)
strBuffer = Replace(strBuffer, “%MOBILE%”, strMobi)
strBuffer = Replace(strBuffer, “%EMAIL%”, strEmai)
strBuffer = Replace(strBuffer, “%AREA%”, strArea)
intLineCount = intLineCount + 1
objSignatureFile.WriteLine strBuffer
Wend
objHTMLSourceFile.Close
Set objHTMLSourceFile = Nothing
objSignatureFile.Close
Set objSignatureFile = Nothing
Set objFSO = Nothing
Set objShell = Nothing
Set objNetwork = Nothing
objFile.Close

 

If you get an error 8007007E you may need the user to run “regsvr32 scrrun.dll” on the user’s PC first.