#204544 - 2012-03-22 05:49 PM
Setting Outlook Signature from Kix script
|
andy_neenan
Just in Town
Registered: 2012-03-15
Posts: 4
Loc: England
|
Hi all,
I have inherited ownership of a Kix login script on our work domain, and need to make some slight modifications.
This is the current script for the Outlook signature section
;Set outlook email signature ;
? " " ? "SET EMAIL SIGNATURE" ? " " $appData = ExpandEnviromentVars(%appdata%) DEL $appData + "\Microsoft\Signatures\AD Signature.*" /c /f
$objSysInfo = CreateObject("ADSystemInfo") $strUser = $objSysInfo.UserName $objUser = GetObject("LDAP://" + $strUser) $strName = $objUser.FullName $strTitle = $objUser.Title $strDepartment = $objUser.Department $strCompany = $objUser.Company $strPhone = $objUser.telephoneNumber $strMail = $objUser.mail $strMobile = $objUser.mobile $strFax = $objUser.facsimileTelephoneNumber $strPost = $objUser.postalCode $strStreet = $objUser.streetAddress $strStreet = REPLACE($strStreet, CHR(10), " ") $strStreet = REPLACE($strStreet, CHR(11), " ") $strStreet = REPLACE($strStreet, CHR(12), " ") $strStreet = REPLACE($strStreet, CHR(13), " ") $strCity = $objUser.l $strOffice = $objUser.physicalDeliveryOfficeName $strWebsite = $objUser.wWWHomePage $strAddress = $strStreet + " " + $strCity + " " + $strPost
$objWord = CreateObject("Word.Application")
$objDoc = $objWord.Documents.Add() $objSelection = $objWord.Selection
$objEmailOptions = $objWord.EmailOptions $objSignatureObject = $objEmailOptions.EmailSignature $objSignatureEntries = $objSignatureObject.EmailSignatureEntries
$objSelection.Font.Name = "Arial" $objSelection.Font.Size = "9" $objSelection.Font.Bold = "1" $objSelection.Font.Color = "6710886" $objSelection.TypeText($strName) $objSelection.TypeText(Chr(11)) $objSelection.TypeText($strTitle) $objSelection.Font.Size = "8" $objSelection.TypeText(Chr(11)) $objSelection.TypeText(Chr(11)) $objSelection.TypeText($strCompany) $objSelection.TypeText(Chr(11)) $objSelection.Font.Bold = "0" $objSelection.TypeText($strAddress) $objSelection.TypeText(Chr(11)) if $strPhone <> "" $objSelection.TypeText("T: " + $strPhone) $objSelection.TypeText(Chr(11)) endif if $strMobile <> "" $objSelection.TypeText("M: " + $strmobile) $objSelection.TypeText(Chr(11)) endif if $strWebsite <> "" $objSelection.TypeText("W: " + $strWebsite) endif
$objSelection = $objDoc.Range()
$objSignature=$objSignatureEntries.Add("AD Signature", $objSelection) $objSignatureObject.NewMessageSignature = "AD Signature" $objSignatureObject.ReplyMessageSignature = "AD Signature"
$objDoc.Saved = 1 $objWord.Quit
I have two additions I need to make
1. If a user is in a certain AD container or group (e.g. IT), I want the script to only input the users NAME and job title, and then some set text that is to be defined in the script.
2. As you can see from the script, it sets the created signature as both the New and Reply signature. I need the script to set a Reply signature that includes only the Users name and job title.
Is the above possible?
Any help is greatly appreciated
Thanks
|
|
Top
|
|
|
|
#204545 - 2012-03-22 06:12 PM
Re: Setting Outlook Signature from Kix script
[Re: andy_neenan]
|
Mart
KiX Supporter
   
Registered: 2002-03-27
Posts: 4673
Loc: The Netherlands
|
Hi Andy,
I'm using a similar style script for our outlook sigs. In our environment it contains some features requested by the marketing department and required by company policy like adding a marketing banner, disclaimer text, etc... We had some issues at first with Word taking some time to close and the script started the next line before Word had actually fully shutdown so I placed a short sleep for half a second just after $objWord.Quit to allow Word to close. After the sleep I call the EnumProccess UDF to see if Word is still running and kill it if it is.
Below is and example of what you could do. I did not test the code so run some tests first.
;Set outlook email signature
;
? " "
? "SET EMAIL SIGNATURE"
? " "
$appData = ExpandEnviromentVars(%appdata%)
Del $appData + "\Microsoft\Signatures\AD Signature.*" /c /f
$objSysInfo = CreateObject("ADSystemInfo")
$strUser = $objSysInfo.UserName
$objUser = GetObject("LDAP://" + $strUser)
$strName = $objUser.FullName
$strTitle = $objUser.Title
$strDepartment = $objUser.Department
$strCompany = $objUser.Company
$strPhone = $objUser.telephoneNumber
$strMail = $objUser.mail
$strMobile = $objUser.mobile
$strFax = $objUser.facsimileTelephoneNumber
$strPost = $objUser.postalCode
$strStreet = $objUser.streetAddress
$strStreet = REPLACE($strStreet, Chr(10), " ")
$strStreet = REPLACE($strStreet, Chr(11), " ")
$strStreet = REPLACE($strStreet, Chr(12), " ")
$strStreet = REPLACE($strStreet, Chr(13), " ")
$strCity = $objUser.l
$strOffice = $objUser.physicalDeliveryOfficeName
$strWebsite = $objUser.wWWHomePage
$strAddress = $strStreet + " " + $strCity + " " + $strPost
;Start creating long sig
$objWord = CreateObject("Word.Application")
$objDoc = $objWord.Documents.Add()
$objSelection = $objWord.Selection
$objEmailOptions = $objWord.EmailOptions
$objSignatureObject = $objEmailOptions.EmailSignature
$objSignatureEntries = $objSignatureObject.EmailSignatureEntries
$objSelection.Font.Name = "Arial"
$objSelection.Font.Size = "9"
$objSelection.Font.Bold = "1"
$objSelection.Font.Color = "6710886"
If InGroup("ITPeople")
$objSelection.TypeText($strName)
$objSelection.TypeText(Chr(11))
$objSelection.TypeText($strTitle)
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("Put whatever text you want here")
Else
$objSelection.TypeText($strName)
$objSelection.TypeText(Chr(11))
$objSelection.TypeText($strTitle)
$objSelection.Font.Size = "8"
$objSelection.TypeText(Chr(11))
$objSelection.TypeText(Chr(11))
$objSelection.TypeText($strCompany)
$objSelection.TypeText(Chr(11))
$objSelection.Font.Bold = "0"
$objSelection.TypeText($strAddress)
$objSelection.TypeText(Chr(11))
If $strPhone <> ""
$objSelection.TypeText("T: " + $strPhone)
$objSelection.TypeText(Chr(11))
EndIf
If $strMobile <> ""
$objSelection.TypeText("M: " + $strmobile)
$objSelection.TypeText(Chr(11))
EndIf
If $strWebsite <> ""
$objSelection.TypeText("W: " + $strWebsite)
EndIf
EndIf
$objSelection = $objDoc.Range()
$objSignature = $objSignatureEntries.Add("New message sig", $objSelection)
$objSignatureObject.NewMessageSignature = "New message sig"
$objDoc.Saved = 1
$objWord.Quit
;Start creating short sig.
$objWord = CreateObject("Word.Application")
$objDoc = $objWord.Documents.Add()
$objSelection = $objWord.Selection
$objEmailOptions = $objWord.EmailOptions
$objSignatureObject = $objEmailOptions.EmailSignature
$objSignatureEntries = $objSignatureObject.EmailSignatureEntries
$objSelection.Font.Name = "Arial"
$objSelection.Font.Size = "9"
$objSelection.Font.Bold = "1"
$objSelection.Font.Color = "6710886"
$objSelection.TypeText($strName)
$objSelection.TypeText(Chr(11))
$objSelection.TypeText($strTitle)
If InGroup("ITpeople")
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("Put whatever text you want here")
EndIf
$objSignature = $objSignatureEntries.Add("Reply message sig", $objSelection)
$objSignatureObject.ReplyMessageSignature = "Reply message sig"
$objDoc.Saved = 1
$objWord.Quit
_________________________
Mart
- Chuck Norris once sold ebay to ebay on ebay.
|
|
Top
|
|
|
|
#204643 - 2012-04-05 04:59 PM
Re: Setting Outlook Signature from Kix script
[Re: Mart]
|
andy_neenan
Just in Town
Registered: 2012-03-15
Posts: 4
Loc: England
|
Hi Mart,
Thanks very much for your help with this, and apologies for the delay.
I have now inserted your script into a test script, replacing the relevant section in my original script. I added my unique info, and set up a test user in the relevant group and logged in with it on a domain machine. Nothing else within the script has changed.
I am now getting errors on login using the test user and test script about "error: error in use statement" on lines PRIOR to the new code being inserted.
Would there be a reason for this? I am still fairly new to these login scripts so any assistance in troubleshooting this would be great.
Thanks
Andy
**EDIT** - Found the problem
@HOMESHR was the line previous to the new signature script - it wasnt defined on the AD profile - now working.
The Reply signature doesnt work yet though - looking into that as we speak.
Thanks again
Edited by andy_neenan (2012-04-05 05:16 PM)
|
|
Top
|
|
|
|
Moderator: Jochen, Allen, Radimus, Glenn Barnas, ShaneEP, Ruud van Velsen, Arend_, Mart
|
1 registered
(mole)
and 494 anonymous users online.
|
|
|