Windows Scripting
  Home arrow Windows Scripting arrow Generating Outlook Signatures Based on Act...
ASP Free Forums 
.NET  
ASP  
ASP Code  
ASP.NET  
ASP.NET Code  
BrainDump  
C#  
Code Examples  
Database  
Database Code  
IIS  
Microsoft Access  
MS SQL Server  
Visual Basic.NET  
Windows Scripting  
Windows Security  
XML  
ASP Web Hosting  
ASP.NET Web Hosting 
Mobile Linux 
App Generation ROI 
Windows Web Hosting
 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
WINDOWS SCRIPTING

Generating Outlook Signatures Based on Active Directory Information
By: Luke Niland
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 2
    2008-06-23

    Table of Contents:
  • Generating Outlook Signatures Based on Active Directory Information
  • Checking for Existing Signature File
  • Creating the signature
  • Finishing the Signature File

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Generating Outlook Signatures Based on Active Directory Information


    (Page 1 of 4 )

    Virtually all modern email clients support HTML-based emails, which means you can deliver a web page into people's mailboxes. While this brings up security issues, it also means we can make our email look a lot nicer than plain old text. Most people use this functionality to create an email signature. These normally provide contact information, web sites, company logos, etc. Many end users don’t have the necessary skills to create a nice looking email signature. This article will show you how to create one automatically.

    We will use a VB Script to create an HTML file and populate this with information from the client's user object in the active directory. The HTML file will be saved into the user's Outlook signature folder, but you can use the same basic technique with any modern email client.

    Getting started ... Connecting to the User object in the Active Directory

    So, the first thing we need to do is connect to the client's user object in the active directory. This is surprisingly easy to do. First of all, we will create an object that points to the ADSystemInfo object. This object will give you some basic information about the currently logged in user.

    The information in here is useful, but in our case it does not contain everything we need. What we can do, however, is use the ADSystemInfo.UserName property to open a connection to the active directory LDAP database, which is where the information we are after is held. So the first part of the script will look like this:


    'create the objects and set the initial vars

    Set WshShell = WScript.CreateObject("WScript.Shell")

    Set FileSysObj = CreateObject("Scripting.FileSystemObject")

    Set objADSysInfo = CreateObject("ADSystemInfo")

    Set UserObj = GetObject("LDAP://" & objADSysInfo.UserName)


    You have probably seen the first two lines before; they are creating objects (the shell and file system objects) we will use later.

    The third and fourth lines are what we are using to connect to the active directory. First we are using the ADSystemInfo, and then, using the UserName property of that object, we can create a new object that binds to the client's user in the active directory.

    Now that we have done that, we have access to all the information for the client, and we can use this information in our email signature. Next, the script will use our shell object to build some paths to where we are going to save the new signature file:


    strAppData = WshShell.ExpandEnvironmentStrings("%APPDATA%")

    SigFolder = StrAppData & "MicrosoftSignatures"

    strQuteChr = chr(34)

    SigFile = SigFolder & UserObj.sAMAccountName & ".htm"


    These lines are just using the system environment variable APPDATA so that we know where to build the signature file. We then create an easy to remember variable for the double quote character, and set the name/path of our signature file to be the user's account name in the default signature folder.

    More Windows Scripting Articles
    More By Luke Niland


       · Thanks for a useful article. I may implement this on a web page so that Users can...
       · The line:-SigFolder = StrAppData & "MicrosoftSignatures"should, of course,...
       · Hi - sorry this may seem obvious but I haven't used VB for years (C# used by last...
       · Hi Lucy,The example her is just a vb script, and as far as i'm aware you wont be...
       · Hi "I would make it automatically set the default Auto signature though."I...
     

    WINDOWS SCRIPTING ARTICLES

    - Introducing Two-Way Data Binding using Silve...
    - Silverlight 2.0 Application Development with...
    - Burning Multisession CDs with IMAPI2 in WSH
    - Creating a Silverlight 2.0 Application that ...
    - Burning CDs with the IMAPI2 Control
    - Burning CDs in Windows XP with WSH
    - Advanced Word Object Scripting
    - Reading and Printing Word Documents in WSH
    - Scripting Microsoft Word
    - Using WSH to Catalog MP3 Files
    - Reading MP3 ID3 Tags in WSH
    - A Brief Look at Menus in WPF
    - More Examples of Simplified Image Processing...
    - Completing a WPF To-Do List Application
    - Simplified Image Processing in GDI+





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
    Stay green...Green IT