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
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