Link to home
Start Free TrialLog in
Avatar of alterniTECH
alterniTECH

asked on

Using VBScript to select current signature for Outlook 2007/2010

Does Outlook 2010 handle signatures differently than it does 2003?

I cannot figure out how to assign a signature to Outlook, using VBScript, in 2007, 2010 versions.

The signature is created in the correct folder, the changes appear in the registry, but still it defies me.

It will replace the existing signature that we have set up (AD Signature) if I run this script with the "strSigVersion = AD Signature" but will not switch to a new one with a different name (ex: "strSigVersion = AD SignatureV1") when the script is run.

What must I do?

(It works in Outlook 2003)

On Error Resume Next

Set objShell = WScript.CreateObject("WScript.Shell")
strUserName = objShell.ExpandEnvironmentStrings("%username%")
 
If Not objExclude.Exists(strUserName) Then
	'DO STUFF HERE....


'>>>Creates Email Signature

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")
 
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)
 
strName = objUser.FullName
strTitle = objUser.Title
strAddress = objUser.streetAddress
strCity = objUser.l
strState = objUser.st
strZip = objUser.postalCode
strCompany = objUser.Company
strPhone = objUser.telephoneNumber
strTfree = objUser.otherTelephone
strFax = objUser.faxNumber
strExt = objUser.ipPhone
strEmail = objUser.mail
strWeb = objUser.wWWHomePage
strMobile = objuser.mobile
strSAMAccountName = objuser.sAMAccountName

'SIGNATURE VERSION
strSigVersion = "AD Signature"

Set objShell = CreateObject("WScript.Shell")
 
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature" , strSigVersion
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature" , strSigVersion
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"

objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\NewSignature" , strSigVersion
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\ReplySignature" , strSigVersion
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\14.0\Common\MailSettings\NewSignature" , strSigVersion
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Common\MailSettings\ReplySignature" , strSigVersion
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\14.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"

 
'Const wdColorBlack = 0
'Const wdColorRed = 128
'Const wdColorYellow = 32896
'Const wdColorBlue = 8388608


Const wdColorOrange = &H1168B7
Const wdColorBlue = &H4A2500

' FORCE UPPER CASE
'objSelection.Case = wdUpperCase

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 = "Times New Roman"
objSelection.Font.Size = 12
objSelection.Font.Color = wdColorBlue
objSelection.Font.Bold = True
objSelection.Font.SmallCaps = True 
objSelection.TypeText strName & chr(11)

objSelection.Font.Size = 10
objSelection.Font.Bold = False
objSelection.Font.Color = wdColorOrange

 
objSelection.Font.Size = 12
objSelection.Font.Color = wdColorBlue
objSelection.Font.Bold = True
objSelection.TypeText strCompany & chr(11)
objSelection.Font.Bold = False
objSelection.Font.Size = 10
objSelection.Font.Color = wdColorOrange 
objSelection.TypeText strAddress & chr(11)
objSelection.TypeText strCity & ", " & strState & "  " & strZip
objSelection.Font.SmallCaps = False
objSelection.TypeText " " & chr(11) & chr(11)

objSelection.Hyperlinks.Add objSelection.Range,"mailto:" & strEmail,, strEmail, strEmail & chr(11)
objSelection.Font.SmallCaps = False
objSelection.Font.Color = wdColorBlue
 
objSelection.TypeText strPhone & " - Direct"  & chr(11)
If strMobile <> "" Then 
objSelection.TypeText strMobile & " - Mobile"  & chr(11)

End If
objSelection.TypeText strTfree & ", Ext. " & strExt & " - Toll Free"  & chr(11)
objSelection.TypeText strFax & " - Fax" & chr(11)

objSelection.Font.Color = wdColorOrange
objSelection.TypeText "Click this! Visit "
objSelection.Font.Color = wdColorBlue
objSelection.Hyperlinks.Add objSelection.Range,"http://" & strWeb,, "Visit our website", strWeb

objSelection.TypeText chr(11) & chr(11)
 
Set objSelection = objDoc.Range()
 
objSignatureEntries.Add strSigVersion, objSelection
objSignatureObject.NewMessageSignature = strSigVersion
objSignatureObject.ReplyMessageSignature = strSigVersion
 
objDoc.Saved = True
objWord.Quit 

End If

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of alterniTECH
alterniTECH

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial