Link to home
Start Free TrialLog in
Avatar of MTSDL
MTSDLFlag for United Kingdom of Great Britain and Northern Ireland

asked on

outlook signature created from details pulled from Active directory

Hi,

i am trying to find/create a script that will run when you logon. I need it to pull details about the user from AD and set a default signature in outlook 2003 and 2000 using the details from the general tab in AD, for example

"Kind Regards
 <display name>

 <description>

 <telephone number>
 <email>

 >>also want an image to appear here<<
"Disclaimer here"

I would be VERY greatful if someone could point me in the direction of some code that i could modify to achieve this. I have tried googling for code but when deploying it to a test user via a GP it doesnt seem to work.

The image has to be at the bottom and must not conflict with any non outlook clients (ie must always display correctly) This is also going to be deployed to citrix clients.

Many thanks in advance
Avatar of purplepomegranite
purplepomegranite
Flag of United Kingdom of Great Britain and Northern Ireland image

This is quite a complex request, but should be possible.  If you have already got some code that purports to do what you want but isn't working, would you be able to post it up here?  It will be a lot quicker than building a script from scratch.  It will be quite easy to see if the code should work, and what problem is preventing it from working.
Avatar of MTSDL

ASKER

Here is the code that gets the fields from AD you can see where i have added a note  where i need to add an image in also.

do you know what i need to write to insert my desired image there

many thanks in adance
'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
 
'Get Signature Info from Word
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 = "11.0"
objSelection.Font.Name = "Arial"
 
objSelection.TypeText "Kind Regards" 
objSelection.TypeText(chr(11))
objSelection.TypeText strName 
objSelection.TypeText(Chr(11))
objSelection.TypeText strTitle
objSelection.TypeText(Chr(11))
objSelection.TypeText strMail
objSelection.TypeText(Chr(11))
objSelection.TypeText "Telephone: " & strPhone
objSelection.TypeText(Chr(11))
objSelection.TypeText '"Main Fax: " & strFax ' can de comment this is i want this field
objSelection.TypeText(Chr(11))
objSelection.TypeText strCompany 
objSelection.TypeText(Chr(11))
objSelection.TypeText strAddress
objSelection.TypeText(Chr(11))
objSelection.TypeText 'strCity & ", " & strState & " " & strZip ' can de comment this is i want this field
objSelection.TypeText(Chr(11))
objSelection.TypeText strWeb
objSelection.TypeText(Chr(11))
objSelection.TypeText(Chr(11))
objSelection.TypeText strInfo
''>>NEED TO INSERT IMAGE HERE<<
 
 
Set objSelection = objDoc.Range()
 
objSelection.Style = "No Spacing"
 
'Write and Save the Signature
objSignatureEntries.Add "Default", objSelection
objSignatureObject.NewMessageSignature = "Default"
objSignatureObject.ReplyMessageSignature = "Default"

Open in new window

Interesting.... maybe the request isn't as complex as I thought!  Though that is an incomplete script, I will quite easily be able to get it working as far as adding signatures is concerned.  There may be issues as a log-on script (I don't know if that part of Outlook can be accessed without Outlook being open), but I'll test this and I'm sure there will be a way.

One thing I have noticed - it is assuming that Word is being used as your email editor.  Is this a safe assumption, or could some users be using Outlook as the editor?

I'll post back later.
Avatar of MTSDL

ASKER

oh sorry the script works, here is the rest of it
' VBScript source code
On Error Resume Next
 
Dim strUser,strName,strTitle,strMail,strPhone,strFax
Dim strCompany,strLocation,strAddress,strCity,strState
Dim strZip,strWeb,strInfo,ADObject
 
'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
 
'Get Signature Info from Word
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 = "11.0"
objSelection.Font.Name = "Arial"
 
objSelection.TypeText "Kind Regards" 
objSelection.TypeText(chr(11))
objSelection.TypeText strName 
objSelection.TypeText(Chr(11))
objSelection.TypeText strTitle
objSelection.TypeText(Chr(11))
objSelection.TypeText strMail
objSelection.TypeText(Chr(11))
objSelection.TypeText "Telephone: " & strPhone
objSelection.TypeText(Chr(11))
objSelection.TypeText '"Main Fax: " & strFax ' can de comment this is i want this field
objSelection.TypeText(Chr(11))
objSelection.TypeText strCompany 
objSelection.TypeText(Chr(11))
objSelection.TypeText strAddress
objSelection.TypeText(Chr(11))
objSelection.TypeText 'strCity & ", " & strState & " " & strZip ' can de comment this is i want this field
objSelection.TypeText(Chr(11))
objSelection.TypeText strWeb
objSelection.TypeText(Chr(11))
objSelection.TypeText(Chr(11))
objSelection.TypeText strInfo
 
 
Set objSelection = objDoc.Range()
 
objSelection.Style = "No Spacing"
 
'Write and Save the Signature
objSignatureEntries.Add "Default", objSelection
objSignatureObject.NewMessageSignature = "Default"
objSignatureObject.ReplyMessageSignature = "Default"
 
'Save and Close Word
objDoc.Saved = True
objWord.Quit
 
'Connect to Registry
Dim objShell, RegKey
Set objShell =  CreateObject("WScript.Shell")
 
'Disable Change of Signature for the User
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\NewSignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Common\MailSettings\ReplySignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"
 
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\NewSignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Common\MailSettings\ReplySignature" , "Default"
objShell.RegWrite "HKEY_CURRENT_USER\Software\Microsoft\Office\12.0\Outlook\Options\Mail\EnableLogging" , "0", "REG_DWORD"
 
Set objShell = Nothing

Open in new window

Avatar of MTSDL

ASKER

you mention about word as the editor, we didnt use to use this as it used to mess up our old html stationary, we are now getting rid of the stationary and replacing it with this auto generated signature which should have an image below the text pulled from AD.

What im saying is if there are no issues that you know of using word as editor im happy to use it
Avatar of MTSDL

ASKER

also i see what you mean about needing outlook open, i just tested it and it doesnt work unless outlook is open, is there a command that i could add to open outlook 1st as most users will load outlook up 1st anyways. and we may only run the script once to mass deploy the signature
Avatar of MTSDL

ASKER

but many users will be using outlook as editor
ASKER CERTIFIED SOLUTION
Avatar of MTSDL
MTSDL
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial