Announcement

Collapse
No announcement yet.

VBS for Outlook Signature

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • VBS for Outlook Signature

    Hiya

    I have been asked find a way to standardize Outlook signatures across the domain. So first thing I do is Google, which returned various scripting ideas.

    This is one I have been playing with, I think I am right in saying I need this script to look right, then I need to set it to run at logon + also set the GPO to use this signature file.

    Anyways, here it is:

    Code:
    On Error Resume Next
    Set objSysInfo = CreateObject("ADSystemInfo")
    strUser = objSysInfo.UserName
    Set objUser = GetObject("LDAP://" & strUser)
    strConfid = "Confidentiality Notice: The information contained within this email is intended for the addressee only.  The message may contain confidential information, and the wrongful distribution or communication of such information is prohibited.  If you receive this email in error please notify the sender immediately by reply email and delete the email including any attachments."
    strFname = objUser.FirstName
    strLname = objUser.LastName
    strInitial = objUser.Initials
    strTitle = objUser.Title
    strDepartment = objUser.Department
    strCompany = objUser.Company
    strPhone = objUser.telephoneNumber
    strFax = objUser.faxnumber
    Set objWord = GetObject(, "Word.Application")
    If objWord Is Nothing Then
    Set objWord = CreateObject("Word.Application")
    blnWeOpenedWord = True
    End If
    Set objDoc = objWord.Documents.Add()
    Set objSelection = objWord.Selection
    Set objEmailOptions = objWord.EmailOptions
    Set objSignatureObjects = objWord.EmailOptions.EmailSignature
    Set objSignatureEntries = objSignatureObjects.EmailSignatureEntries
    objSelection.Style = "No Spacing"
    'Name
    objselection.Font.Bold = true
    objSelection.TypeText UCase(strFname) & " "
    if strInitial then objSelection.TypeText UCase(strInitial) & ". "
    objSelection.TypeText UCase(strLname)
    if strTitle then objSelection.TypeText ", " & strTitleo
    bjSelection.TypeText Chr(11)
    objselection.Font.Bold = false
    if strDepartment then objSelection.TypeText strDepartment & Chr(11) 
    objSelection.TypeText Chr(11)
    objSelection.TypeText strCompany & Chr(11)
    objSelection.TypeText strStreet & Chr(11)
    objSelection.TypeText strCSZ & Chr(11)
    objSelection.TypeText "Phone: " & strPhone & Chr(11)
    objSelection.TypeText "Fax: " & strFax & Chr(11)
    objSelection.TypeText strToll & Chr(11) & Chr(11)
    objSelection.TypeText strConfid
    Set objSelection = objDoc.Range()
    objSignatureEntries.Add "AD Signature", objSelection
    objSignatureObjects.NewMessageSignature = "AD Signature"
    objSignatureObjects.ReplyMessageSignature = "AD Signature"
    objDoc.Close 0
    If blnWeOpenedWord Then
    objWord.Quit
    End If
    Now I have absolutely no knowledge on scripting at all, I just pick at the basics.

    The few things I am stuck on are:

    How do I change font, size, bold, italic, etc?
    How would I tell it to insert a picture (company logo)
    Which field in AD is it pulling the Title from??????? I tried the obvious one called Title but it pulls blank data.

    I think ultimately the idea is to have something like:

    NAME
    Position/Title
    Logo
    Phone #
    Fax #
    Discalimer

    I appreciate any help!

  • #2
    Re: VBS for Outlook Signature

    Anyone?

    Comment


    • #3
      Re: VBS for Outlook Signature

      Hi,

      From my experience, the standard way of dealing with signatures across a domain is to use a third party app on your exchange server such as Exclaimer.

      Comment


      • #4
        Re: VBS for Outlook Signature

        Thanks, will look into that, but my client wants everything for free as usual!

        Comment


        • #5
          Re: VBS for Outlook Signature

          I know that feeling well, although this is the best way of dealing with it. Not sure how many users you have; i think we paid 500 for >100

          All the best with that!

          Comment


          • #6
            Re: VBS for Outlook Signature

            Hmm

            There are about 50 users total...
            I will enquire. Thanks.

            Comment


            • #7
              Re: VBS for Outlook Signature

              Hi Guys,

              A Couple of notes on Signatures for Both Outlook 2003 and 2007

              Local Folder where the signature must be saved:
              %AppData%\Microsoft\Signatures

              To Enforce no changes be made from the client these 2 values must be created in the registry:

              Outlook 2003
              HKCU\Software\Microsoft\Office\11.0\Common\MailSet tings\NewSignature
              HKCU\Software\Microsoft\Office\11.0\Common\MailSet tings\ReplySignature

              Outlook 2007
              HKCU\Software\Microsoft\Office\12.0\Common\MailSet tings\NewSignature
              HKCU\Software\Microsoft\Office\12.0\Common\MailSet tings\ReplySignature

              The Keys "NewSignature" and "ReplySignature" must have the name of your Signature and must be of type "Reg_SZ"

              The Script Posted uses Word to create the signature and once the Saved action is created, you'll notice the files are saved in the above directory.

              To see more what the script below does, enter the following line:

              objWord.Visible = True

              just after the line: Set objWord = CreateObject("Word.Application")

              also add in a couple of stops by entering Echo's:
              WScript.Echo "Paus here"

              Enjoy how word will now open and you can see how the text is entered!

              Dasgood!

              Comment


              • #8
                Re: VBS for Outlook Signature

                I must be in a mood today because this is another post that strikes me as using technology to solve a behavioral problem. If the company wants to use a standard email signature, then someone should create that signature, distribute it to all employees, include it in the AUP, and send a memo to all employess that this is the only approved email signature and must be used by all employees.

                I wonder how much time and money companies spend dealing with this issue from a technology standpoint when it's clearly a management issue?

                At my company we decided that we needed to use a standard email signature for all employees. We had one employee design the new signature and distribute it to all employees and then management sent out a mandate that the new signature is the only one to be used in all email communication.

                Comment


                • #9
                  Re: VBS for Outlook Signature

                  I Totally agree with you, but then again from a Management Point of view, you'd like to have standards.

                  With users that just never read their mails or listens, this is one way of using and abusing Technology to get what you want!
                  Last edited by Dasgood; 29th May 2009, 14:30.

                  Comment


                  • #10
                    Re: VBS for Outlook Signature

                    Try something like this VBS script...I have added comments to somewhat explain what is going on. This is the script I wrote to standardize signatures at my last job, and it worked well as a logon script.

                    Code:
                    ' This script is for creating unified Outlook signatures using Group Policy.  It runs as a logon script.
                    ' This is public domain, compiled with a lot of trial and error and reading about e-mail signature scripting.  If you want to
                    ' change things, be my guest.  Certainly someone has better ideas than I do :)
                    ' Places that helped me:
                    '    http://technet.microsoft.com/en-us/m...iptingguy.aspx
                    '    http://episteme.arstechnica.com/eve/...m/572003134831
                    '    http://social.msdn.microsoft.com/for...-a0ccf5939ed7/
                    ' My username is eramnes and this was posted on 5/29/09, but written sometime last year.
                    ' I can't offer support on this, but I'll do what I can. I just hope it is useful and saves some money versus a paid solution.
                    ' Thanks to everyone who helped me out when I was writing this.
                    ' The script will take quite a while(20-30 seconds) to run at logon, and it will flash Outlook on the screen for a split second
                    ' when it adds the signature in.  It's invisible the rest of the time though.
                    On Error Resume Next
                    ' Set up a line break definition - if you don't do this, when the signature is displayed in HTML it will have an extra line break
                    ' between each line.  *We* all send e-mail as plain text though anyway, right :)
                    Const WdLineBreak = 6
                    Dim intLen
                    Set objSysInfo = CreateObject("ADSystemInfo")
                    strUser = objSysInfo.UserName
                    Set objUser = GetObject("LDAP://" & strUser)
                    ' Pull our signature information from AD.  You can figure out names using ADSI Edit, they are just LDAP properties.  Please make 
                    ' sure to fill out all these fields if you are going to use them, if you have users missing one field it will display a blank
                    ' line in the signature, and you don't want that!  If this is more information than you want, just comment them out or delete
                    ' the ones you don't want.
                    strName = objUser.FullName
                    strTitle = objUser.Title
                    strAddress = objUser.streetAddress
                    strCity = objUser.physicalDeliveryOfficeName
                    strState = objUser.st
                    strZip = objUser.postalCode
                    strCompany = objUser.Company
                    strDirect = objUser.homePhone
                    strFax = objUser.faxNumber
                    strEmail = objUser.mail
                    strPhone = objuser.telephoneNumber
                    strWWW = "insert your website address here (keep the quotes around it though)"
                    ' Create an integer that will tell us how long the last two fields are in characters - without this number you can't apply text
                    ' formatting to the URL string, because it will only do part of the URL...not sure why though, some sort of limitation in
                    ' VBscripted Word I guess.  Why strFax?  Trial and error :) The method listed in the Ars article doesn't quite work for me,
                    ' because I didn't have any text in front of the URL.  Follow Ars if you want it to be easy :)
                    ' But it works with arbitrary length information in any field, so no worries.
                    intLen = Len(strFax) + Len(strWWW)
                    ' Make a new Word application, but don't show it in the desktop session
                    Set objWord = CreateObject("Word.Application")
                    ' Create a new document, this is where the text will go for the signature
                    Set objDoc = objWord.Documents.Add()
                    Set objSelection = objWord.Selection
                    Set objEmailOptions = objWord.EmailOptions
                    Set objSignatureObject = objEmailOptions.EmailSignature
                    Set objSignatureEntries = objSignatureObject.EmailSignatureEntries
                    ' Don't use extra spaces at all
                    objSelection.ParagraphFormat.SpaceAfter = 0
                    ' Here is where we set the font size, style, etc.  Please use fonts that are installed on everyone's system - I don't know how to
                    ' make it check the installed state first :)  If you want multiple font sizes or styles, you have to change it after each string
                    ' that you are having it add.  You'll see in the example where I change the font size a couple times by adding new Font.Size
                    ' selections.
                    objSelection.Font.Size = "13.5"
                    objSelection.Font.Name = "Franklin Gothic Medium"
                    objSelection.TypeText strName
                    objSelection.Font.Size = "10"
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strTitle
                    objSelection.InsertBreak WdLineBreak
                    objSelection.Font.Size = "10"
                    objSelection.TypeText strCompany
                    objSelection.Font.Size = "9"
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strAddress
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strCity & ", " & strState & " " & strZip
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText "Phone: " & strPhone
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText "Direct: " & strDirect
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText "Fax: " & strFax
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strEmail
                    objSelection.InsertBreak WdLineBreak
                    ' Create a new hyperlink that will be clickable
                    objSelection.Hyperlinks.Add objSelection.Range, " " & strWWW & " ", , , strWWW, "_blank"
                    ' Here is where the magic starts...without this step your formatting will only apply to about half of the URL string.  The program
                    ' needs to know how long the string is in order to select and format it, this is where the intLen from before comes into play.
                    Set objSelection = objDoc.Range(objSelection.End-intLen,objSelection.End)
                    objSelection.Font.Name = "Franklin Gothic Medium"
                    objSelection.Font.Size = "9"
                    Set objSelection = objDoc.Range()
                    ' Add the signature to Outlook for New Messages as the signature name AD New Message.  You can change this if you want to.  Just
                    ' replace the value in quotes with the name you want.
                    objSignatureEntries.Add "AD New Message", objSelection
                    objSignatureObject.NewMessageSignature = "AD New Message"
                    objDoc.Saved = True
                    objWord.Quit
                    ' Now on to creating a signature for replies.  This will make a shorter signature with less info for e-mails
                    ' that people reply to.  Since they've already made contact, the people shouldn't need to have so much information.
                    On Error Resume Next
                    Set objSysInfo = CreateObject("ADSystemInfo")
                    strUser = objSysInfo.UserName
                    Set objUser = GetObject("LDAP://" & strUser)
                    strName = objUser.FullName
                    strTitle = objUser.Title
                    strCompany = objUser.Company
                    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.Size = "10"
                    objSelection.Font.Name = "Franklin Gothic Medium"
                    objSelection.TypeText strName
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strCompany
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText "Direct: " & strDirect
                    objSelection.InsertBreak WdLineBreak
                    objSelection.TypeText strEmail
                    Set objSelection = objDoc.Range()
                    objSignatureEntries.Add "AD Reply", objSelection
                    objSignatureObject.ReplyMessageSignature = "AD Reply"
                    objDoc.Saved = True
                    objWord.Quit
                    Don't fool yourself. If you truly feel passionate about something, you will do whatever it takes. If you don't, you'd better get busy pursuing happiness, because it's all you've got.

                    Comment

                    Working...
                    X