Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

VBScript for outlook signature from Active Directory

$
0
0

Hi, I have been asked to put together a vb script for my company to be able to use to pull signatures from AD. I have put together a script and it works fine and the info is the way it should be. Just a couple of things I cannot work out.

1. How do I hyperlink the email address

2. How do I hyperlink the website.

3. How do I add the facebook and twitter picture and then hyperlink the picture to the relevant websites

My codes is below and any help is appreciated.

On Error Resume Next

Dim strUser,strName,strTitle,strMail,strPhone,strFax
Dim strCompany,strLocation,strAddress,strCity,strState
Dim strZip,strWeb,strInfo,ADObject

strSourceDir=replace(wscript.scriptfullname,wscript.scriptname,"")

Set fso=CreateObject("Scripting.FileSystemObject")
Set objSysInfo = CreateObject("ADSystemInfo")
Set WshShell = CreateObject("WScript.Shell")

                            'Active Directory Info Object
Set ADObject = CreateObject("ADSystemInfo")

strUser = ADObject.UserName

                            'Active Directory Connection
Set objUser = GetObject("LDAP://" & strUser)

                            'Pull Active Directory Info for this User
strName = objUser.FullName
strTitle = objUser.Title
strMail = objUser.Mail
strPhone = objUser.telephoneNumber
strFax = objUser.Faxnumber
strCompany = objUser.Company
strLocation = objuser.physicalDeliveryOfficeName
strAddress = objuser.streetAddress
strCity = objuser.l
strState = objuser.st
strZip = objuser.postalCode
strWeb = objuser.wWWHomePage
strInfo = objuser.info
strpobox = objuser.postofficebox

Dim objFSO, objWsh, appDataPath, pathToCopyTo, plainTextFile
Dim plainTextFilePath, richTextFile, richTextFilePath, htmlFile, htmlFilePath

Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objWsh = CreateObject("WScript.Shell")
appDataPath = objWsh.ExpandEnvironmentStrings("%APPDATA%")
pathToCopyTo = appDataPath & "\Microsoft\Signatures\"


'Create HTML Signature
htmlFilePath = pathToCopyTo & "Default.htm"
Set htmlFile = objFSO.CreateTextFile(htmlFilePath, TRUE)
htmlfile.WriteLine("<body>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-weight:bold;font-family:Arial;color:#943634"">" & strName & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-weight:bold;font-family:Arial;color:#943634"">" & strTitle & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">" & strCompany & "</div>")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">Thompson Court</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">9F Silver Street</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">Wellingborough</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">NN8 1BQ</div")
htmlfile.WriteLine("<br>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;""> Direct Line: " & strPhone & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;""> Email: " & strMail & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;"">" & StrWeb & "</div>")
htmlfile.WriteLine("<br><br>")
htmlfile.WriteLine("</div>")
htmlfile.WriteLine("</body>")
htmlfile.Write("</html>")
htmlFile.Close

'Create HTML Relpy Signature
htmlFilePath = pathToCopyTo & "Reply.htm"
Set htmlFile = objFSO.CreateTextFile(htmlFilePath, TRUE)
htmlfile.WriteLine("<body>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-weight:bold;font-family:Arial;color:#943634"">" & strName & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-weight:bold;font-family:Arial;color:#943634"">" & strTitle & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">" & strCompany & "</div>")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">Thompson Court</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">9F Silver Street</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">Wellingborough</div")
htmlFile.WriteLine("<div style=""font-size:10pt;font-family:Arial;color:#943634"">NN8 1BQ</div")
htmlfile.WriteLine("<br>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;""> Direct Line: " & strPhone & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;""> Email: " & strMail & "</div>")
htmlfile.WriteLine("<div style=""font-size:10pt;font-family:Arial;"">" & StrWeb & "</div>")
htmlfile.WriteLine("<br>")
htmlfile.WriteLine("</div>")
htmlfile.WriteLine("</body>")
htmlfile.Write("</html>")
htmlFile.Close

Set objFSO = Nothing
Set objWsh = Nothing

'Connect to Registry
Dim objShell, RegKey
Set objShell =  CreateObject("WScript.Shell")


objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & strOutlookVersion & "\Common\MailSettings\NewSignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & strOutlookVersion & "\Common\MailSettings\ReplySignature" , "Reply"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\" & strOutlookVersion & "\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"

Set objShell = Nothing


Viewing all articles
Browse latest Browse all 15028

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>