-
1
- #1
Chuck091956
Programmer
Hello All,
I've build a VBS script to dynamically create a user's Outlook Signature files. It works off their logon ID and Active Directory and builds the user's .HTM, .RTF & .TXT files in their Signature folder.
Some of the parameters have been hard coded in my example but you could make it more dynamic. I build this because we use Mandatory Profiles and needed a way to let users have a reasonable Signature.
Use at your own risk and have fun!
Chuck Peck
I've build a VBS script to dynamically create a user's Outlook Signature files. It works off their logon ID and Active Directory and builds the user's .HTM, .RTF & .TXT files in their Signature folder.
Some of the parameters have been hard coded in my example but you could make it more dynamic. I build this because we use Mandatory Profiles and needed a way to let users have a reasonable Signature.
Use at your own risk and have fun!
Chuck Peck
Code:
'==========================================================================
'
' VBScript: <Outlook_Signatures.vbs>
' AUTHOR: Chuck Peck
' Contact Info: chuck091956@optonline.net
' Version 1.1
' Date: January 31, 2005
'
' COMMENT: Key concepts are listed below:
'1. This script gets user info from AD and plugs it into vars to create Outlook signature files.
'2. Replace all web_address with your real address.
'3.
'==========================================================================
Option Explicit
Dim qQuery
Dim objSysInfo
Dim objuser
Set objSysInfo = CreateObject("ADSystemInfo")
'objSysInfo.RefreshSchemaCache
qQuery = "LDAP://" & objSysInfo.Username
Dim FullName
Dim EMail
Dim Title
Dim PhoneNumber
Dim FaxNumber
Dim OfficeLocation
Dim web_address
' Asigns the user's info to variables.
'==========================================================================
Set objuser = GetObject(qQuery)
FullName = objuser.displayname
EMail = objuser.mail
Title = objuser.description
PhoneNumber = objuser.telephoneNumber
FaxNumber = objuser.facsimileTelephoneNumber
OfficeLocation = objuser.physicalDeliveryOfficeName
' This section creates the signature files names and locations.
'==========================================================================
Dim FolderLocation
Dim LogonID
Dim TexTFileString
Dim RTFFileString
Dim HTMFileString
web_address = "[URL unfurl="true"]http://www.youraddress.com"[/URL]
LogonID = objuser.sAMAccountName
FolderLocation = "C:\Documents and Settings\" & LogonID & "\Application Data\Microsoft\Signatures\"
TexTFileString = FolderLocation & "Default.txt"
RTFFileString = FolderLocation & "Default.rtf"
HTMFileString = FolderLocation & "Default.htm"
' This section figures out where the user works.
'==========================================================================
Dim StreetAddress
Dim Town
Dim State
Dim ZipCode
Dim TollFreeNumber
' Edit this section as needed.
If OfficeLocation = "MD" Then
StreetAddress = "Street Name, Suite 210,"
Town = "Town,"
State = "MD"
ZipCode = "XXXXX"
TollFreeNumber = "(800) xxx-xxxx"
ElseIf OfficeLocation = "NJ" Then
StreetAddress = "Street Name,"
Town = "Town,"
State = "NJ"
ZipCode = "XXXXX"
TollFreeNumber = "(800) xxx-xxxx"
Else
StreetAddress = "Street Name, Suite 603,"
Town = "Town,"
State = "MA"
ZipCode = "XXXXX"
TollFreeNumber = "(800) xxx-xxxx"
End If
' Thes next 3 sections builds the signature files
'==========================================================================
Dim objFSO
Dim objFile
Dim aQuote
aQuote = chr(34)
' This section builds the text file version
'==========================================================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(TexTFileString)
objFile.Close
Set objFile = objFSO.OpenTextFile(TexTFileString, 2)
objfile.write FullName & vbCrLf
objfile.write Title & vbCrLf
' Replace Company-name with your company name
objfile.write "company_name" & vbCrLf
objfile.write StreetAddress & vbCrLf
objfile.write Town & " " & State & " " & ZipCode & vbCrLf
objfile.write "Office " & TollFreeNumber & " " & PhoneNumber & " Fax " & FaxNumber & vbCrLf
objfile.write web_address & vbCrLf
objFile.Close
' This section builds the HTML file version
'==========================================================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(HTMFileString)
objFile.Close
Set objFile = objFSO.OpenTextFile(HTMFileString, 2)
objfile.write "<!DOCTYPE HTML PUBLIC " & aQuote & "-//W3C//DTD HTML 4.0 Transitional//EN" & aQuote & ">" & vbCrLf
objfile.write "<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>" & vbCrLf
objfile.write "<META http-equiv=Content-Type content=" & aQuote & "text/html; charset=windows-1252" & aQuote & ">" & vbCrLf
objfile.write "<META content=" & aQuote & "MSHTML 6.00.3790.186" & aQuote & " name=GENERATOR></HEAD>" & vbCrLf
objfile.write "<BODY>" & vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080><STRONG>" & FullName & "</STRONG></FONT></DIV>" &
vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2><EM>" & Title & "</EM></FONT></DIV>" &
vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>Castle Point Mortgage, Inc.</FONT></DIV>" &
vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>" & StreetAddress & "</FONT></DIV>" & vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>" & Town & " " & State & " " & ZipCode &
"</FONT></DIV>" & vbCrLf
objfile.write "<DIV align=left><FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>Office " & TollFreeNumber & " " &
PhoneNumber & " Fax " & FaxNumber & "</FONT></DIV>" & vbCrLf
objfile.write "<DIV align=left><FONT face=Arial size=2><A href=" & aQuote & web_address & aQuote & ">" & web_address & "</A></FONT></DIV>" & vbCrLf
objfile.write "<DIV align=left><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>" & vbCrLf
objFile.Close
' This section builds the RTF file version
'==========================================================================
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.CreateTextFile(RTFFileString)
objFile.Close
Set objFile = objFSO.OpenTextFile(RTFFileString, 2)
objfile.write "{\rtf1\ansi\ansicpg1252\fromhtml1 \deff0{\fonttbl" & vbCrLf
objfile.write "{\f0\fswiss\fcharset0 Arial;}" & vbCrLf
objfile.write "{\f1\fmodern Courier New;}" & vbCrLf
objfile.write "{\f2\fnil\fcharset2 Symbol;}" & vbCrLf
objfile.write "{\f3\fmodern\fcharset0 Courier New;}" & vbCrLf
objfile.write "{\f4\fswiss Century Schoolbook;}" & vbCrLf
objfile.write "{\f5\fswiss Arial;}}" & vbCrLf
objfile.write "{\colortbl\red0\green0\blue0;\red0\green0\blue255;\red0\green0\blue128;}" & vbCrLf
objfile.write "\uc1\pard\plain\deftab360 \f0\fs24 " & vbCrLf
objfile.write "{\*\htmltag243 <!DOCTYPE HTML PUBLIC " & aQuote & "-//W3C//DTD HTML 4.0 Transitional//EN" & aQuote & ">}" & vbCrLf
objfile.write "{\*\htmltag3 \par }" & vbCrLf
objfile.write "{\*\htmltag19 <HTML>}" & vbCrLf
objfile.write "{\*\htmltag34 <HEAD>}" & vbCrLf
objfile.write "{\*\htmltag177 <TITLE>}" & vbCrLf
objfile.write "{\*\htmltag241 Microsoft Office Outlook Signature}" & vbCrLf
objfile.write "{\*\htmltag185 </TITLE>}" & vbCrLf
objfile.write "{\*\htmltag1 \par }" & vbCrLf
objfile.write "{\*\htmltag1 \par }" & vbCrLf
objfile.write "{\*\htmltag161 <META content=" & aQuote & "MSHTML 6.00.3790.186" & aQuote & " name=GENERATOR>}" & vbCrLf
objfile.write "{\*\htmltag41 </HEAD>}" & vbCrLf
objfile.write "{\*\htmltag2 \par }" & vbCrLf
objfile.write "{\*\htmltag50 <BODY>}" & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080>}\htmlrtf {\f4 \cf2 \htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag84 <STRONG>}\htmlrtf {\b \htmlrtf0 " & Fullname & vbCrLf
objfile.write "{\*\htmltag92 </STRONG>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 \par size=2>}\htmlrtf {\f4 \cf2 \fs20 \htmlrtf0 " &
vbCrLf
objfile.write "{\*\htmltag84 <EM>}\htmlrtf {\i \htmlrtf0 " & Title & vbCrLf
objfile.write "{\*\htmltag92 </EM>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>}\htmlrtf {\f4 \cf2 \fs20 \htmlrtf0 Castle
Point Mortgage, Inc." & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>}\htmlrtf {\f4 \cf2 \fs20 \htmlrtf0 " &
StreetAddress & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>}\htmlrtf {\f4 \cf2 \fs20 \htmlrtf0 " & Town
& " " & State & " " & ZipCode & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=" & aQuote & "Century Schoolbook" & aQuote & " color=#000080 size=2>}\htmlrtf {\f4 \cf2 \fs20 \htmlrtf0 Office "
& TollFreeNumber & " " & PhoneNumber & " Fax " & FaxNumber & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=Arial size=2>}\htmlrtf {\f5 \fs20 \htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag84 <A \par href=" & aQuote & web_address & aQuote & ">}\htmlrtf {\field{\*\fldinst{HYPERLINK " & aQuote & web_address & aQuote &
"}}{\fldrslt\cf1\ul \htmlrtf0" & web_address & "\htmlrtf }\htmlrtf0 \htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag92 </A>}" & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag0 \par }" & vbCrLf
objfile.write "{\*\htmltag96 <DIV align=left>}\htmlrtf {\ql \htmlrtf0 {\*\htmltag64}\htmlrtf {\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag148 <FONT face=Arial size=2>}\htmlrtf {\f5 \fs20 \htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag156 </FONT>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag84 }\htmlrtf \'a0\htmlrtf0 {\*\htmltag72}\htmlrtf\par}\htmlrtf0" & vbCrLf
objfile.write vbCrLf
objfile.write "{\*\htmltag104 </DIV>}\htmlrtf }\htmlrtf0 " & vbCrLf
objfile.write "{\*\htmltag58 </BODY>}" & vbCrLf
objfile.write "{\*\htmltag27 </HTML>}" & vbCrLf
objfile.write "{\*\htmltag3 \par }}" & vbCrLf
objFile.Close