Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty line in Outlook 2003 Signature after running VB script 1

Status
Not open for further replies.

Scod

Technical User
Jun 10, 2010
3
NL
Hey guys,

I am a absolute newbie to VBS and have a slite problem with the script I came across a script which works perfectly except one thing.
If I run the script it creates the signature including our company logo at the top of the new e-mail message but above the logo there are 2 empty lines.

How can ik get rid off these lines?

Thanks sofar,
Chris

Script:
'================
'
'VBScript: <Signatures.VBS)
'AUTHOR: Chris Olde (colde@home.nl)
'Contact Info: Chris Olde
'Version 2.00
'Date: 1 juni 2010
'Modified: 9 juni 2010
'=================

'Option Explicit
On Error Resume Next

Set objSysInfo = CreateObject("ADSystemInfo")

Set WshShell = CreateObject("WScript.Shell")

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

strName = objuser.cn
strTitle = objUser.Title
strCred = objUser.info
strStreet = objUser.StreetAddress
strLocation = objUser.l
strCounty = objuser.st
strPostCode = objUser.PostalCode
strCity = objUser.City
strCompany = objUser.Company
StrDepartment = objUser.Department
strPhone = objUser.TelephoneNumber
strMobile = objUser.Mobile
strFax = objUser.FacsimileTelephoneNumber
strEmail = objUser.mail

Set objWord = CreateObject("Word.Application")

Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
Set objShape = objSelection.InlineShapes.AddPicture("\\servername\logo.jpg")
objSelection.Font.Color = RGB(1,13,98)
objSelection.Font.Name = "Tahoma"
objSelection.Font.Size = 10
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
objSelection.TypeText Chr(13)
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
objSelection.TypeText Chr(13)
objSelection.TypeText "Beste , "
objselection.TypeText Chr(13)
objselection.TypeText Chr(13)
objselection.TypeText Chr(13)
objSelection.TypeParagraph()
objSelection.Font.Bold = True
objSelection.TypeText strName
objselection.TypeText Chr(13)
if (StrDepartment) Then objSelection.TypeText strDepartment & Chr(13)
objSelection.Font.Bold = False
objSelection.Font.Name = "Tahoma"
objSelection.Font.Size = 10
objSelection.TypeText Chr(13)
objselection.TypeText Chr(13)
objSelection.TypeText "Companyname"
objSelection.TypeText Chr(13)
objSelection.TypeText "2nd name"
objSelection.TypeText Chr(13)
objSelection.TypeText Chr(13)
objSelection.TypeText strStreet
objSelection.TypeText Chr(13)
objSelection.Typetext strPostCode & " " & strCounty
objSelection.TypeText Chr(13)
objSelection.TypeText Chr(13)
objSelection.TypeText "T: " & strPhone
objSelection.TypeText Chr(13)
if (strFax) Then objSelection.TypeText "F: " & strFax & Chr(13)
if (strMobile) Then objSelection.TypeText "Mobile: " & strMobile & Chr(13)
objSelection.TypeText Chr(13)
objSelection.Font.Name = "Tahoma"
objSelection.TypeText "E-mail: "
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"mailto:" & strEmail ,,,strEmail)
objselection.TypeText Chr(13)
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"Set objSelection = objDoc.Range()

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

objDoc.Saved = True
objWord.Quit

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 = "Tahoma"
objSelection.Font.Color = RGB(1,13,98)
objSelection.Font.Size = 10
objSelection.TypeParagraph()
objSelection.Font.Bold = True
if (strCred) Then objSelection.TypeText strName & ", " & strCred Else objSelection.TypeText strName
objSelection.TypeText strTitle
objSelection.Font.Bold = False
objSelection.TypeText Chr(13)
objselection.TypeText Chr(13)
objSelection.TypeText "Comapny name"
objSelection.TypeText Chr(13)
objSelection.TypeText "2nd name"
objSelection.TypeText Chr(13)
objSelection.TypeText Chr(13)
objSelection.TypeText strStreet
objSelection.TypeText Chr(13)
objSelection.Typetext strPostCode & " " & strCounty
objSelection.TypeText Chr(13)
objSelection.TypeText Chr(13)
objSelection.TypeText "T: " & strPhone
objSelection.TypeText Chr(13)
if (strFax) Then objSelection.TypeText "F: " & strFax & Chr(13)
if (strMobile) Then objSelection.TypeText "Mobile: " & strMobile & Chr(13)
objSelection.TypeText Chr(13)
objSelection.Font.Name = "Tahoma"
objSelection.TypeText "E-mail: "
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"mailto:" & strEmail ,,,strEmail)

objselection.TypeText Chr(13)
objLink = objSelection.Hyperlinks.Add(objSelection.Range,"
Set objSelection = objDoc.Range()

objSignatureEntries.Add "Reply Signature", objSelection

objSignatureObject.ReplyMessageSignature = "Reply Signature"

objDoc.Saved = True
objWord.Quit
 
Delete or comment out marked lines...

Code:
'================
{Truncated}...
Set objShape = objSelection.InlineShapes.AddPicture("\\servername\logo.jpg")
objSelection.Font.Color = RGB(1,13,98)
objSelection.Font.Name = "Tahoma"
objSelection.Font.Size = 10
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
[s]objSelection.TypeText Chr(13)[/s]
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
[s]objSelection.TypeText Chr(13)[/s]
objSelection.TypeText "Beste , " 
objselection.TypeText Chr(13)
objselection.TypeText Chr(13)
objselection.TypeText Chr(13)
...{Truncated}

PSC
[&mdash;] CCNP [&bull;] CCSP [&bull;] MCITP: Enterprise Admin [&bull;] MCSE [&mdash;]

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Ok, gotcha. The problem you're having is not with the signature or signature file, so you can disregard my last post.

You're actually fighting the default behavior of Outlook. When Outlook is told to add the signature, it programatically adds 2 CRLF characters, then adds whatever signature data is passed to it. You don't have a choice.

I suppose that you could look at using the WShell SendKeys method to fire off a couple of backspace characters, but that seems ugly.

Really, after looking at it, is this really a problem? Most users want a bit of space between the text they typed and their signature.

PSC
[&mdash;] CCNP [&bull;] CCSP [&bull;] MCITP: Enterprise Admin [&bull;] MCSE [&mdash;]

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
PscottC,

thnxs again. Now I can explain the 2 CRLF at the top of the new message in Outlook 2003. I will try to find a work-around to get the logo at the top of the message and ad the signature in the way we want.

Chris.
 
You should look at Outlook Forms. I think that's where you'll need to be.

PSC
[&mdash;] CCNP [&bull;] CCSP [&bull;] MCITP: Enterprise Admin [&bull;] MCSE [&mdash;]

Governments and corporations need people like you and me. We are samurai. The keyboard cowboys. And all those other people out there who have no idea what's going on are the cattle. Mooo! --Mr. The Plague, from the movie "Hackers
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top