Solved

Using VBScript to select current signature for Outlook 2007/2010

Posted on 2010-09-16
1
2,609 Views
Last Modified: 2012-05-10
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

0
Comment
Question by:alterniTECH
1 Comment
 

Accepted Solution

by:
alterniTECH earned 0 total points
ID: 33695785
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Learn more about how the humble email signature can be used as more than just an electronic business card. When used correctly, a signature can easily be tailored for different purposes by different departments within an organization.
This process describes the steps required to Import and Export data from and to .pst files using Exchange 2010. We can use these steps to export data from a user to a .pst file, import data back to the same or a different user, or even import data t…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This video shows how to remove a single email address from the Outlook 2010 Auto Suggestion memory. NOTE: For Outlook 2016 and 2013 perform the exact same steps. Open a new email: Click the New email button in Outlook. Start typing the address: …

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now