locked
Auto generate outlook Signature VB Script RRS feed

  • Question

  • Dear technet users,

     

    I have edit a script from Scriptcentre. The script generates your outlook signature automaticly it pulls information from the Active Directory. It is all working perfect and the signature is also working perfect the following problem is that i need to add a image below the signature, but when you click on the image it will open a website. Is this possible in VBS? I have searched for hours, but i can't find it.

    Is anyone able to help me or point me in the right direction?

     

    '========================== 
    ' 
    ' ############### Script that creates a standard company signature for all users (in a corporate environment); pulling data from Active Directory - dynamic logo insertion depending on department field if needed. 
    ' 
    ' Original by Severn Dickinson 
    '
    ' Big up to Script Centre 
    ' 
    ' 17-01-2011. 
    ' 
    '=========================== 
     
     
    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 
    strWeb = objuser.wWWHomePage 
    strNotes = objuser.info 
    strExt = objuser.ipPhone 
    strDDI = objuser.homephone 
    strEmailTEXT = "Email: " 
     
     
     
    ' ########### 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 
     
     
     
    ' ########### Calls the variables from above section and inserts into word template, also sets initial font typeface, colour etc. 
     
    objSelection.Font.Name = "Cambria" 
    objSelection.Font.Size = 10 
    objselection.Font.Bold = false 
    objSelection.Font.Color = RGB (000,000,000) 
     
    objSelection.TypeParagraph()
     
    objselection.typetext "Met Vriendelijke groeten (Kind Regards),"
    objSelection.TypeParagraph()
    objSelection.TypeParagraph() 
    objSelection.TypeText strGiven & " " & strSurname 
    
    objSelection.Font.Size = 10 
    objSelection.TypeText "" 
    objselection.TypeText strnotes 
    objselection.TypeText Chr(11) 
    objSelection.Font.Size = 10 
    objselection.Font.Bold = false 
    objSelection.TypeText strTitle & Chr(11) 
    objselection.TypeText Chr(11) 
     
     
     
    ' ########### Logos insert routine. 
     
     
    If (objUser.Department = "COMPANY NAME.") Then 
                 objSelection.InlineShapes.AddPicture("\\jsddom01\data\image001.gif") 
     
     
    ElseIf (objUser.Department = "COMPANY NAME") Then 
            objSelection.InlineShapes.AddPicture("\\jsddom01\data\image001.gif") 
     
    Else 
            objSelection.InlineShapes.AddPicture("\\jsddom01\data\image001.gif") 
     
    End If 
     
      
    ' ############ 1 Column en 1 Row
     
     
    objselection.TypeText Chr(11) 
      
    Const Number_of_rows = 12 
    Const Number_of_columns = 2 
    Const END_OF_STORY = 12 
     
    objSelection.TypeParagraph() 
    Set objRange = objSelection.Range 
    objDoc.Tables.Add objRange, number_of_rows, number_of_columns 
     
    Set objTable = objDoc.Tables(1) 
     
    If (objUser.postofficebox = "") Then 
     
      objTable.Cell(1, 1).Range.Text = strCompany
      objTable.Cell(2, 1).Range.Text = strAddress1 
      objTable.Cell(3, 1).Range.Text = strPostcode 
      objTable.Cell(4, 1).Range.Text = strAddress2 
      objTable.Cell(5, 1).Range.Text = strAddress3 
     
    Else 
    
      objTable.Cell(1, 1).Range.Text = strCompany 
      objTable.Cell(2, 1).Range.Text = strAddress1 
      objTable.Cell(3, 1).Range.Text = strAddress1EXT 
      objTable.Cell(4, 1).Range.Text = strPostcode 
      objTable.Cell(5, 1).Range.Text = strAddress2 
      objTable.Cell(6, 1).Range.Text = strAddress3
     
    End If 
     
     
    objTable.Cell(7, 1).Range.Text = "Tel: " & strPhone & " | Ext: " & strExt 
    objTable.Cell(8, 1).Range.Text = "Fax: " & strFax 
    objTable.Cell(9, 1).Range.Text = "Mobile: " & strMobile 
     
     
    '### Makes a clickable hyperlink. 
     
    Set objCell = objTable.Cell(10, 1) 
    Set objCellRange = objCell.Range 
    objCell.Select 
    objSelection.TypeText "Web: " 
    Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "http://www.website.com", , , "www.website.com") 
      objLink.Range.Font.Name = "Cambria" 
      objLink.Range.Font.Size = 10 
      objLink.Range.Font.Bold = false 
      objSelection.Font.Color = RGB (000,045,154) 
     
     
    '### Makes a clickable mailto: email address based on the users AD information. 
     
    Set objCell = objTable.Cell(11, 1) 
    Set objCellRange = objCell.Range 
    objCell.Select 
    objselection.typeText strEmailTEXT 
    Set objLink = objSelection.Hyperlinks.Add(objSelection.Range, "mailto: " & strEmail, , , strEmail) 
      objLink.Range.Font.Name = "Cambria" 
      objLink.Range.Font.Size = 10 
      objLink.Range.Font.Bold = false 
     
     
    objTable.AutoFitBehavior(1) 
     
    objSelection.EndKey END_OF_STORY 
    
    '### Clickable Facebook Link
    NEED A IMAGE WICH LINKS TO A WEBSITE
    
     
     
    ' ########### Tells outlook to use this signature for new messages and replys. Signature is called Email Signature. 
     
    Set objSelection = objDoc.Range() 
    objSignatureEntries.Add "Email Signature", objSelection 
    objSignatureObject.NewMessageSignature = "Email Signature" 
    objSignatureObject.ReplyMessageSignature = "Email Signature" 
     
     
    objDoc.Saved = True 
     
    objWord.Quit

    Tuesday, January 18, 2011 2:46 PM

Answers

  • This should do it, obviously just change the url to what ever you want:

    Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("\\jsddom01\data\image001.gif"), "http://www.microsoft.com",,,"")

    • Marked as answer by Caase.com Wednesday, January 19, 2011 12:39 PM
    Wednesday, January 19, 2011 11:42 AM

All replies

  • Still can't find it, going out of my mind.
    Wednesday, January 19, 2011 9:04 AM
  • This should do it, obviously just change the url to what ever you want:

    Set objLink = objSelection.Hyperlinks.Add(objSelection.InlineShapes.AddPicture("\\jsddom01\data\image001.gif"), "http://www.microsoft.com",,,"")

    • Marked as answer by Caase.com Wednesday, January 19, 2011 12:39 PM
    Wednesday, January 19, 2011 11:42 AM
  • Thanks so much!!! Signature is finished now and ready to get pushed via GPO thanks man!
    Wednesday, January 19, 2011 12:37 PM
  •  Hi,

     

    I have tested your script, and make my changes.

    It works perfect, but I have a little detail.

     

    I am trying to change the color of the email and link (lets say, apply a grey color), but I always get it underlined and blue color.

     

    Does anybody know how to change it?

     

    Thanks in advance,

     

    Monday, June 27, 2011 7:29 PM
  • Color can't be changed directly.  You have to change the link style settings with HyperLink, FollowedHyperlink style which is global to the document.

     


    jv
    Tuesday, June 28, 2011 4:54 PM
  • Great script, but I have one question. I changed the default font into Verdana. When I create a new mail the font is OK, but when I reply to a message, the font is Times New Roman. Anyone knows how this can happen?
    Friday, July 1, 2011 1:27 PM
  • I happen to stuble upon this script (sorry for the necro, just didnt felt it was needed for a new topic for my question)

    Script works wonderfull (altho the line about needing a facebook link needed to be commented out ;-)

    http://img403.imageshack.us/img403/9498/doubletable.png

    link above is how i would like to see the table setup....

    on the left the information stuff like name, adres, phone, etc, etc and on the right our company logo...

    Any one knows to to work this out?

    I figured doing it with tables is gonna be easier then doing it with "image behind text" ...


    • Edited by dutch2007 Thursday, May 24, 2012 12:37 PM
    Thursday, May 24, 2012 12:29 PM
  • I happen to stuble upon this script (sorry for the necro, just didnt felt it was needed for a new topic for my question)

    Script works wonderfull (altho the line about needing a facebook link needed to be commented out ;-)

    http://img403.imageshack.us/img403/9498/doubletable.png

    link above is how i would like to see the table setup....

    on the left the information stuff like name, adres, phone, etc, etc and on the right our company logo...

    Any one knows to to work this out?

    I figured doing it with tables is gonna be easier then doing it with "image behind text" ...


    Please start a new topic.  This one has been answered and closed.  YOur issue also constitutes a whole different question.

    You should really post questions about Word tables in the Office developers forum.

    For signatures use a template to set the format and just insert teh data into bookmarks that have been established in the template.


    ¯\_(ツ)_/¯

    Thursday, May 24, 2012 2:27 PM
  • I have changed the link color in our signature.

    Here is the entire line for the link:

    objFile.Write "<a href=""" &strWeb & """ style=""FONT-SIZE: 8pt; COLOR:#000000; text-decoration:none; FONT-FAMILY: Arial"""

    &StrWeb & is of course a variable that you have to define. text-decoration:none; removes the underline, In case you aren't familiar with html :)

    Sorry if this is a bit late :)

    / Johan

    Monday, March 4, 2013 12:38 PM
  • do you have the final script available ?
    Friday, November 10, 2017 9:45 PM