Tuesday, January 15, 2013

Outlook /Exchange - Signature

Hi Readers,

Just want to share an intersting script that I have found on the Internet but want to share with viewers of this blog.

If you want to implement signatures but don't want to use thrid-party products or don't want to use exchange 2010 tranport rule solution then below

outlook solution will help you.

Below vbscript can be run from C:\scripts\signature

copy your company logo in that folder too..

This can be packaged & distributed/ pushed thru tools like SCCM.


----------------------------------------------------------------------------------------------------------------------------------
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
strSignatureName = "Signature Name"
strLogoPath = "C:\scripts\signature\boston-scientific-logo.gif"
strGiven = objuser.givenName
strSurname = objuser.sn
strAddress1 = objUser.streetAddress
strAddress1EXT = objUser.postofficebox
strAddress2 = objuser.l
strAddress3 = objuser.st
strPostcode = objuser.postalcode
strExt = objuser.homephone
strTitle = objUser.Title
strEmail =objuser.mail
strCompany = objUser.Company
strPhone = objUser.telephoneNumber
strFax = objUser.facsimileTelephoneNumber
strMobile = objuser.mobile
REM strWeb = objuser.wWWHomePage
REM strNotes = objuser.info
REM strDepartment = objUser.Department
REM strIP = objuser.ipPhone
REM strEmailTEXT = "Email: "
REM strCountry = objuser.c
' ### Sets up word template
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
'### creates a table in the word document with one row and two cells
objselection.TypeText Chr(11)

Const Number_of_rows = 1
Const Number_of_columns = 2
Const END_OF_STORY = 1
objSelection.TypeParagraph()
Set objRange = objSelection.Range
objDoc.Tables.Add objRange, number_of_rows, number_of_columns
Set objTable = objDoc.Tables(1)
objTable.AutoFitBehavior(1)
'### Sets up the first cell with the logo inside
Set objCell = objTable.Cell(1, 1)
Set objCellRange = objCell.Range
objSelection.Range = objCell.Range
objSelection.InlineShapes.AddPicture(strLogoPath)
'### Sets up the second cell as follows
'###           
'###            <br>'###            <email><br>'###            <company><br>'###            <address> , <city>, <state> <zip><br>'###            Tele: <office number>, Extension:<extention><br>'###            Mobile: <mobile number>, Fax: <fax number></p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> Set objCell = objTable.Cell(1, 2)<br>Set objCellRange = objCell.Range<br>objCell.Select</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### Set up the formatting for the name and title<br>objSelection.Font.Name = "Verdana"<br>objSelection.Font.Size = 10<br>objSelection.Font.Bold = True<br>objSelection.Font.Color = RGB (032,178,089)</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### Type the name and title<br>objSelection.TypeText     strGiven & " " & strSurname & Chr(11) &_<br>             strTitle & Chr(11)</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### Set up the formatting for the name and title<br>objSelection.Font.Size = 8<br>objSelection.Font.Bold = False<br>objSelection.Font.Color = RGB (018,123,190)</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### check to see if the mobile number is listed and add it to the signature if it exists<br>IF Len(strMobile) = 12 Then<br>    objSelection.TypeText     strEmail & Chr(11) &_<br>                            strCompany & Chr(11) &_<br>                            strAddress1 & ", " & strAddress2 & ", " & strAddress3 & " " & strPostcode & Chr(11) &_<br>                            "Tele:" & strPhone & ", Extension:" & strExt & Chr(11) &_<br>                            "Mobile:" & strMobile & ", " & "Fax:" & strFax   <br>Else<br>    objSelection.TypeText     strEmail & Chr(11) &_<br>                            strCompany & Chr(11) &_<br>                            strAddress1 & ", " & strAddress2 & ", " & strAddress3 & " " & strPostcode & Chr(11) &_<br>                            "Tele:" & strPhone & ", Extension:" & strExt & Chr(11) &_<br>                            "Fax:" & strFax<br>End If</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### set the signature up as strSignatureName and tell outlook to use it as default<br>Set objSelection = objDoc.Range()<br>objSignatureEntries.Add strSignatureName, objSelection<br>objSignatureObject.NewMessageSignature = strSignatureName<br>objSignatureObject.ReplyMessageSignature = strSignatureName</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> '### save the signature<br>objDoc.Saved = True</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> objWord.Quit</p> <p style="color: rgb(51, 51, 51); font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; font-size: 13px; line-height: 19px;"> ----------------------------------------------------------------------------------------------------------------------------------</p> <p> </p> <p> <br></p> <p> Regards</p> <p> <br></p> <p> Sukhija Vikas</p> </div>

No comments:

Post a Comment