Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

vbscript signature on Outlook 2007 and Outlook 2010

Posted on 2012-08-22
4
Medium Priority
?
2,233 Views
Last Modified: 2012-08-23
Hi there,

We have the script below set up using a .vbs script that runs when our users log onto the domain.  The Outlook signature it creates with Outlook 2003 looks great, but it doesn't look right with Outlook 2007 or Outlook 2010.  With 2007 and 2010, it adds extra spaces between each line break.  How can we fix it?  Thank you!

On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

strName = objUser.firstname+" "+objUser.lastname
strTitle = objUser.Title
if strTitle = "" then
      strTitle = objUser.Description
end if

strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.HomePhone
if strPhone = "" then
      strPhone = objUser.TelephoneNumber
end if
strDirectPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strEmail = objuser.mail
strFax = objUser.facsimileTelephoneNumber

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

'Set doc = createobject("Word.ActiveDocument")

objSelection.InlineShapes.AddHorizontalLineStandard
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "8"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeParagraph()
objSelection.TypeText strName
objSelection.TypeParagraph()
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText strTitle
objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "8"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeParagraph()
objSelection.Font.Name = "arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText "t:  " & strPhone
if strDirectPhone <> "" then
      objSelection.TypeParagraph()
      objSelection.TypeText "d: " & strDirectPhone
end if
if strMobile <> "" then
      objSelection.TypeParagraph()
      objSelection.TypeText "c: " & strMobile
end if
objSelection.TypeParagraph()
objSelection.TypeText "f:  " & strfax
objSelection.TypeParagraph()
objSelection.TypeText strEmail
'doc.Hyperlinks.Add objSelection.Range, "mailto:" & strEmail, , , strEmail
objSelection.TypeParagraph()
objSelection.TypeText strWebpage
'objSelection.Font.Color = RGB(53,85,12)
'objDoc.Hyperlinks.Add objSelection.Range, strWebpage,,,strWebpage
objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.TypeParagraph()
objSelection.Font.Name = "webdings"
objSelection.Font.Size = "12"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(0,153,0)
objSelection.TypeText "P"
objSelection.TypeText " "
objSelection.Font.Name = "times new roman"
objSelection.Font.Size = "10"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(0,153,0)
objSelection.TypeText "Please consider the environment before printing this email"
objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.TypeParagraph()
objSelection.Font.Name = "arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText "This e-mail and any files transmitted with it are confidential and intended solely for the use of the addressee. This e-mail shall not be deemed binding unless confirmed in writing. If you have received it by mistake, please let us know by e-mail reply and delete it from your system; you may not copy this message or disclose its contents to anyone. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission."

Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD Signature", objSelection
objSignatureObject.NewMessageSignature = "AD Signature"

objDoc.Saved = True
objWord.Quit
0
Comment
Question by:Christian Palacios
  • 2
  • 2
4 Comments
 
LVL 59

Accepted Solution

by:
Bill Prew earned 2000 total points
ID: 38322008
Give this a try, seems to work better on Outlook 2010 for me.  I can't explain why yet, but I saw a number of examples on the web where rather than doing Paragraph between lines they send a Chr(11) out instead.  Seemed to work here.

On Error Resume Next

strWebPage = ""

Set objSysInfo = CreateObject("ADSystemInfo")

strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

strName = objUser.firstname+" "+objUser.lastname
strTitle = objUser.Title
if strTitle = "" then
      strTitle = objUser.Description
end if

strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.HomePhone
if strPhone = "" then
      strPhone = objUser.TelephoneNumber
end if
strDirectPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strEmail = objuser.mail
strFax = objUser.facsimileTelephoneNumber

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

'Set doc = createobject("Word.ActiveDocument")

objSelection.InlineShapes.AddHorizontalLineStandard
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "8"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText strName
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText strTitle
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.Font.Name = "Arial"
objSelection.Font.Size = "8"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.Font.Name = "arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText "t:  " & strPhone
if strDirectPhone <> "" then
      objSelection.TypeText chr(11) '       objSelection.TypeParagraph()
      objSelection.TypeText "d: " & strDirectPhone
end if
if strMobile <> "" then
      objSelection.TypeText chr(11) '       objSelection.TypeParagraph()
      objSelection.TypeText "c: " & strMobile
end if
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText "f:  " & strfax
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText strEmail
'doc.Hyperlinks.Add objSelection.Range, "mailto:" & strEmail, , , strEmail
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText strWebpage
'objSelection.Font.Color = RGB(53,85,12)
'objDoc.Hyperlinks.Add objSelection.Range, strWebpage,,,strWebpage
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.Font.Name = "webdings"
objSelection.Font.Size = "12"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(0,153,0)
objSelection.TypeText "P"
objSelection.TypeText " "
objSelection.Font.Name = "times new roman"
objSelection.Font.Size = "10"
objSelection.Font.Bold = True
objSelection.Font.Color = RGB(0,153,0)
objSelection.TypeText "Please consider the environment before printing this email"
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.TypeText " "
objSelection.TypeText chr(11) ' objSelection.TypeParagraph()
objSelection.Font.Name = "arial"
objSelection.Font.Size = "7.5"
objSelection.Font.Bold = False
objSelection.Font.Color = RGB(153,153,153)
objSelection.TypeText "This e-mail and any files transmitted with it are confidential and intended solely for the use of the addressee. This e-mail shall not be deemed binding unless confirmed in writing. If you have received it by mistake, please let us know by e-mail reply and delete it from your system; you may not copy this message or disclose its contents to anyone. Please note that any views or opinions presented in this e-mail are solely those of the author and do not necessarily represent those of the company. E-mail transmission cannot be guaranteed to be secure or error-free. The sender therefore does not accept liability for any errors or omissions in the contents of this message, which arise as a result of e-mail transmission."

Set objSelection = objDoc.Range()

objSignatureEntries.Add "AD Signature", objSelection
objSignatureObject.NewMessageSignature = "AD Signature"

objDoc.Saved = True
objWord.Quit

Open in new window

~bp
0
 

Author Comment

by:Christian Palacios
ID: 38327015
Thanks very much, that worked!

Christian
0
 

Author Closing Comment

by:Christian Palacios
ID: 38327020
Great advice!
0
 
LVL 59

Expert Comment

by:Bill Prew
ID: 38327023
Great, glad that helped, thanks for the feedback.

~bp
0

Featured Post

Has Powershell sent you back into the Stone Age?

If managing Active Directory using Windows Powershell® is making you feel like you stepped back in time, you are not alone.  For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why.

Question has a verified solution.

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

Are you looking for the options available for exporting EDB files to PST? You may be confused as they are different in different Exchange versions. Here, I will discuss some options available.
With so many activities to perform, Exchange administrators are always busy in organizations. If everything, including Exchange Servers, Outlook clients, and Office 365 accounts work without any issues, they can sit and relax. But unfortunately, it…
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
Suggested Courses

810 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