Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Using VBScript to select current signature for Outlook 2007/2010

Posted on 2010-09-16
1
Medium Priority
?
2,642 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 

Accepted Solution

by:
alterniTECH earned 0 total points
ID: 33695785
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
With User Account Control (UAC) enabled in Windows 7, one needs to open an elevated Command Prompt in order to run scripts under administrative privileges. Although the elevated Command Prompt accomplishes the task, the question How to run as script…
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…
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…

705 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