Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using VBScript to select current signature for Outlook 2007/2010

Posted on 2010-09-16
1
Medium Priority
?
2,646 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 is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes how to import an Outlook PST file to Office 365 using a third party product to avoid Microsoft's Azure command line tool, saving you time.
Mailbox Corruption is a nightmare every Exchange DBA wishes he never has. Recovering from it can be super-hectic if not entirely futile. And though techniques like the New-MailboxRepairRequest cmdlet have been designed to help with fixing minor corr…
This Experts Exchange video Micro Tutorial shows how to tell Microsoft Office that a word is NOT spelled correctly. Microsoft Office has a built-in, main dictionary that is shared by Office apps, including Excel, Outlook, PowerPoint, and Word. When …
To add imagery to an HTML email signature, you have two options available to you. You can either add a logo/image by embedding it directly into the signature or hosting it externally and linking to it. The vast majority of email clients display l…

971 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