Creating email signature automatically

Use the following script as the basis for creating an email signatures from the Active Directory.

Save it as signature.vbs and run the script as a user. You may put the script in the users login script.

On Error Resume Next

Set objSysInfo = CreateObject(“ADSystemInfo”)
Set objWsh = WScript.CreateObject(“WScript.Shell”)

strUser = objSysInfo.UserName
Set objUser = GetObject(“LDAP://” & strUser)

strLogonServer = sh.ExpandEnvironmentStrings(“%LOGONSERVER%”)
IF strLogonServer = “” THEN
strLogonServer = “\\Filesrv”
END IF

‘Pull Active Directory Info for this User
‘General Tab
strName = objUser.FullName
strDescription =objuser.description
strDirectLine = objUser.telephoneNumber
strWeb = objuser.wWWHomePage
strToll= “+1 (888)123-4567”

‘Address Tab
strStreet = objUser.streetAddress
strStreet1 = objUser.postofficebox
strCity = objuser.l
strProvince = objuser.st
strCountry = objUser.co
strPostalCode = objUser.PostalCode

‘Telephones Tab
strext = objUser.homephone
strMobile = objUser.mobile
strFax = objuser.facsimileTelephoneNumber

‘Organization Tab
strTitle = objUser.title
strDepartment = objuser.department
strCompany = objUser.Company

‘Create HTML Signature LOGO

appDataPath = objwsh.ExpandEnvironmentStrings(“%APPDATA%”)
pathToCopyTo = appDataPath & “\Microsoft\Signatures\”
FileName = pathTocopyTo & “Signature_IHS_Logo.htm”

Set objFSO = CreateObject (“Scripting.FileSystemObject”)
‘Set htmlfile = objFSO.CreateTextFile (FileName)
Set htmlfile = objFSO.CreateTextFile (FileName)

htmlfile.WriteLine(“<html>”)
htmlfile.WriteLine(“<head>”)
htmlfile.WriteLine(“<style>”)
htmlfile.WriteLine(“.name {font-weight:bold;font-size:10pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“.text {font-style:normal;font-size:8pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“.btext {font-weight:bold;font-size:8pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“.cname {font-weight:bold;font-size:10pt; font-family:Calibri, Arial, Helvetica, sans-serif;color:#243D82;}”)
htmlfile.WriteLine(“.ctext {font-style:normal;font-size:8pt; font-family:Calibri, Arial, Helvetica, sans-serif;color:#243D82;}”)
htmlfile.WriteLine(“a:link {color:#0000ff;}”)
htmlfile.WriteLine(“a:visited {color:#0000ff;}”)
htmlfile.WriteLine(“</style>”)
htmlfile.WriteLine(“</head>”)
htmlfile.WriteLine(“<body>”)
htmlfile.WriteLine(“<div class=””test””>” & “____________________________”& “</div>”)
htmlfile.WriteLine(“<div class=””name””>” & strName)

if len(strDescription) > 0 then
htmlfile.WriteLine(“, ” & strDescription & “</div>”)
end if

if len(strDescription) = 0 then
htmlfile.WriteLine(“</div>”)
end if

htmlfile.WriteLine(“<div class=””text””>” & strTitle & “</div>”)

if len(strDirectLine) > 0 then
htmlfile.WriteLine(“<div class=””text””>” & “P:&nbsp” & strDirectLine & “</div>”)
end if
if len(strMobile) > 0 then
htmlfile.WriteLine(“<div class=””text””>” & “C:&nbsp” & strMobile & “</div>”)
end if

‘ Change this to where the company logo is stored on the web.
‘ htmlfile.WriteLine(“<img src=http://www.domain.com/images/logo.jpg>”)
htmlfile.WriteLine(“<div class=””ctext””>” & strStreet & “, ” & strCity & “, ” & strProvince & “, ” & strCountry & “</div>”)
htmlfile.WriteLine(“<div class=””ctext””>” & “Toll Free: ” & strToll & “</div>”)
htmlfile.WriteLine(“<div class=””ctext””<a href=””” & StrWeb & “””>” & strWeb & “</a></div>”)

htmlfile.WriteLine(“</body>”)
htmlfile.Write(“</html>”)
htmlFile.Close

‘Create HTML Reply

appDataPath = objwsh.ExpandEnvironmentStrings(“%APPDATA%”)
pathToCopyTo = appDataPath & “\Microsoft\Signatures\”
FileName = pathTocopyTo & “Signature_IHS_Reply.htm”

Set objFSO = CreateObject (“Scripting.FileSystemObject”)
‘Set htmlfile = objFSO.CreateTextFile (FileName)
Set htmlfile = objFSO.CreateTextFile (FileName)

htmlfile.WriteLine(“<html>”)
htmlfile.WriteLine(“<head>”)
htmlfile.WriteLine(“<style>”)
htmlfile.WriteLine(“.name {font-weight:bold;font-size:10pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“.text {font-style:normal;font-size:8pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“.btext {font-weight:bold;font-size:8pt; font-family:Calibri, Arial, Helvetica, sans-serif;}”)
htmlfile.WriteLine(“a:link {color:#0000ff;}”)
htmlfile.WriteLine(“a:visited {color:#0000ff;}”)
htmlfile.WriteLine(“</style>”)
htmlfile.WriteLine(“</head>”)
htmlfile.WriteLine(“<body>”)
htmlfile.WriteLine(“<div class=””name””>” & “Regards,” & “</div>”)
htmlfile.WriteLine(“<div class=””name””>” & strName)

if len(strDescription) > 0 then
htmlfile.WriteLine(“, ” & strDescription & “</div>”)
end if

if len(strDescription) = 0 then
htmlfile.WriteLine(“</div>”)
end if

htmlfile.WriteLine(“<div class=””text””>” & strTitle & “</div>”)
htmlfile.WriteLine(“</body>”)
htmlfile.Write(“</html>”)
htmlFile.Close

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s