Seperator Line in a vbs email template

Ivan Azzopardi 1 Reputation point
2021-06-16T12:50:53.693+00:00

I am trying to insert a separator between the image logo and the table where the data is populated. Can somebody please help me?

On Error Resume Next
Set objSysInfo = CreateObject("ADSystemInfo")

' ########### This section connects to Active Directory as the currently logged on user #####
strUser = objSysInfo.UserName
Set objUser = GetObject("LDAP://" & strUser)

' ########### This section sets up the variables we want to call in the script (items on the left; whereas the items on the right are the active directory database field names) – ie strVariablename = objuser.ad.databasename ########
strGiven = objuser.givenName
strSurname = objuser.sn
strAddress1 = objUser.streetaddress
strAddress1EXT = objUser.postofficebox
strAddress2 = objuser.l
strAddress3 = objuser.st
strPostcode = objuser.postalcode
strCountry = objuser.c
strFax = objuser.facsimileTelephoneNumber
strMobile = objuser.mobile
strTitle = objUser.Title
strDepartment = objUser.Department
strCompany = objUser.Company
strPhone = objUser.telephoneNumber
strEmail =objuser.mail
strEmailTEXT = "Email: "
strWebsite = objuser.wWWHomePage
strNotes = objuser.info
strExt = objuser.ipPhone
strDDI = objuser.homephone

' ########### Sets up word template #####
Wscript.Sleep 500
Set objWord = CreateObject("Word.Application")
Set objDoc = objWord.Documents.Add()
Set objSelection = objWord.Selection
objSelection.Style = "No Spacing"
Set objEmailOptions = objWord.EmailOptions
Set objSignatureObject = objEmailOptions.EmailSignature
Set objSignatureEntries = objSignatureObject.EmailSignatureEntries

'Insert of Information Hosting Table
Set objRange = objDoc.Range()
objDoc.Tables.Add objRange, 11,2
Set objTable = objDoc.Tables(1)
objTable.Columns(1).Width = 100
objTable.Columns(2).Width = 250
objTable.Cell(1,1).Merge objTable.Cell(10,1)

'############# Insert Separator
With Selection.Borders(wdBorderLeft)
.LineStyle = wdLineStyleSingleWavy
.LineWidth = wdLineWidth075pt
.ColorIndex = wdRed
End With

' Company Logo
objTable.Rows(1).Height = 1

If (objUser.Department = "Marketing") Then
objSelection.InlineShapes.AddPicture("\Repos\email_logo_currently_in_use.jpg")
Else
objSelection.InlineShapes.AddPicture("\Repos\email_logo_currently_in_use.jpg")
End If

' Full Name
objTable.Rows(1).Height = 5
objTable.Cell(1, 2).Range.Font.Color = RGB(0,80,175)
objTable.Cell(1, 2).Range.Font.Name = "Calibri"
objTable.Cell(1, 2).Range.Font.Bold = true
objTable.Cell(1, 2).Range.Font.Size = 10
objTable.Cell(1, 2).Range.Text = "left"
objTable.Cell(1, 2).Range.Text = strGiven & " " & strSurname

' Title
objTable.Rows(2).Height = 5
objTable.Cell(2, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(2, 2).Range.Font.Name = "Calibri"
objTable.Cell(2, 2).Range.Font.Bold = true
objTable.Cell(2, 2).Range.Font.Size = 9
objTable.Cell(2, 2).Range.Text = "left"
objTable.Cell(2, 2).Range.Text = strTitle

' Empty Row
objTable.Rows(3).Height = 2
objTable.Cell(3, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(3, 2).Range.Font.Name = "Calibri"
objTable.Cell(3, 2).Range.Font.Bold = true
objTable.Cell(3, 2).Range.Font.Size = 2

' Telephone Office
objTable.Rows(4).Height = 5
objTable.Cell(4, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(4, 2).Range.Font.Name = "Calibri"
objTable.Cell(4, 2).Range.Font.Size = 9
objTable.Cell(4, 2).Range.Text = "left"
objTable.Cell(4, 2).Range.Text = "Tel: " & strPhone

' Telephone Mobile
objTable.Rows(5).Height = 5
objTable.Cell(5, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(5, 2).Range.Font.Name = "Calibri"
objTable.Cell(5, 2).Range.Font.Size = 9
objTable.Cell(5, 2).Range.Text = "left"
If (objuser.mobile = "") Then
objTable.Cell(5, 2).Range.Text = "Mobile: " & "-"
Else
objTable.Cell(5, 2).Range.Text = "Mobile: " & strMobile
End If

' Email
objTable.Rows(6).Height = 5
objTable.Cell(6, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(6, 2).Range.Font.Name = "Calibri"
objTable.Cell(6, 2).Range.Font.Size = 9
objTable.Cell(6, 2).Range.Text = "left"
objTable.Cell(6, 2).Range.Text = "E-mail: " & strEmail

' Empty Row
objTable.Rows(7).Height = 2
objTable.Cell(7, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(7, 2).Range.Font.Name = "Calibri"
objTable.Cell(7, 2).Range.Font.Bold = true
objTable.Cell(7, 2).Range.Font.Size = 2

' Company Website
Set objCell = objTable.Cell(8, 2)
Set objCellRange = objCell.Range
objCell.Select
Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "Web: " & strWebsite, , , strWebsite)
objLink.Range.Font.Name = "Calibri"
objLink.Range.Font.Size = 9
objLink.Range.Font.Bold = false
objSelection.Font.Color = RGB (000,045,154)

' Empty Row
objTable.Rows(9).Height = 2
objTable.Cell(9, 2).Range.Font.Color = RGB(0,0,0)
objTable.Cell(9, 2).Range.Font.Name = "Calibri"
objTable.Cell(9, 2).Range.Font.Bold = true
objTable.Cell(9, 2).Range.Font.Size = 2

'Type the disclaimer'
Set objCell = objTable.Cell(10, 2)
Set objCellRange = objCell.Range
objCell.Select
Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, strWebsite,,, "Please read our legal disclaimer here")
objTable.Rows(10).Height = 5
objTable.Cell(10, 2).Range.Font.Color = RGB(000,045,154)
objTable.Cell(10, 2).Range.Font.Name = "Calibri"
objTable.Cell(10, 2).Range.Font.Size = 6

'Type the Environmental Message'
objTable.Rows(11).Height = 5
objTable.Cell(11, 2).Range.Font.Color = RGB(115,155,63)
objTable.Cell(1, 2).Range.Font.Name = "Calibri"
objTable.Cell(11, 2).Range.Font.Size = 6
objTable.Cell(11, 2).Range.Text = "left"
objTable.Cell(11, 2).Range.Text = "Please consider the environment before printing this e-mail."

' ########### Final Part of the script, tells outlook to use this signature for new messages and reply’s ########
Set objSelection = objDoc.Range()
objSignatureEntries.Add strCompany, objSelection
objSignatureObject.NewMessageSignature = strCompany
objSignatureObject.ReplyMessageSignature = strCompany

'##################################################################################################################
objDoc.Saved = True
objWord.Quit

0 comments No comments
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.