If Not @LOGONMODE
Break on
EndIf
Call @LDRIVE + "\functions\readfile().udf"
;Region Delete old signatures
;Delete all existing signatures.
;Stuff can change. Therefore the signatures are
;deleted and recreated each time.
$appdata = ExpandEnvironmentVars(%appdata%)
Del $appdata + "\Microsoft\Signatures\*.*"
;endregion
;Region Get data
;Get data from AD
$objSysInfo = CreateObject("ADSystemInfo")
$strUser = $objSysInfo.UserName
$objUser = GetObject("LDAP://" + $strUser)
$strName = $objUser.FullName
$strTitle = $objUser.Title
$strMail = $objUser.mail
$strDepartment = $objUser.Department
$strCompany = $objUser.Company
$strStreet = $objUser.StreetAddress
$strPostalCode = $objUser.PostalCode
$strCity = $objUser.L
$strCountry = "The " + $objUser.Co
$strPhone = $objUser.telephoneNumber
$strFax = $objUser.FacsimileTelephoneNumber
$strMobile = $objUser.Mobile
$strWeb = $objUser.wWWHomePage
;endregion
;Region Write Signature
;Set phonecomment for CallCenter.
If $strDepartment = "CallCenter"
$strPhonetxtnl = "Some text goes here"
EndIf
;Read the contents of the news text file.
$strNews = ReadFile(@LDRIVE + "\tools\News.txt")
;Set phone and faxnumber.
$strFax = "000 - 0000" + $strFax
Select
Case Left($strPhone, 1) = "1" And $strDepartment = "CallCenter"
$strPhone = "000 - 0000000"
Case Left($strPhone, 1) = "1" And $strDepartment = "Sales"
$strPhone = "000 - 0000001"
Case Left($strPhone, 1) = "1"
$strPhone = "000 - 0000002"
Case 1
$strPhone = "000 - 0000" + $strPhone
EndSelect
;Initialize word to write the signature.
$objWord = CreateObject("Word.Application")
$objDoc = $objWord.Documents.Add()
$objSelection = $objWord.Selection
$objEmailOptions = $objWord.EmailOptions
$objSignatureObject = $objEmailOptions.EmailSignature
$objSignatureEntries = $objSignatureObject.EmailSignatureEntries
;Write signature.
$objSelection.Font.Name = "Arial"
$objSelection.Font.Size = "10"
$objSelection.TypeText("Kind regards,")
$objSelection.TypeText(Chr(11))
$objSelection.TypeText(Chr(11))
$objSelection.Font.Color = "26367"
$objSelection.Font.Size = "10"
$objSelection.TypeText($strName + " | " + $strTitle)
$objSelection.Font.Size = "9"
$objSelection.TypeText(Chr(11))
$objSelection.TypeText($strCompany)
$objSelection.Font.Color = "8421504"
$objSelection.TypeText(" | " + $strStreet + " | " + $strPostalcode + " | " + $strCity)
$objSelection.TypeText(Chr(11))
If $strMobile <> ""
$objSelection.TypeText("Phone: " + $strPhone + " | " + "Fax: " + $strFax + " | " + "Mobile: " + $strMobile)
Else
$objSelection.TypeText("Phone: " + $strPhone + " | " + "Fax: " + $strFax)
EndIf
$objSelection.TypeText(Chr(11))
$objSelection.TypeText("E-mail: " + $strmail + " | " + "Web: " + $strWeb)
$objSelection.TypeText(Chr(11))
$objSelection.TypeText(Chr(11))
;If there is no news the news file will be empty or
;the news file does not exist. Skip the news part if this is the case.
If UBound($strNews) <> "-1"
For $i = 0 to UBound($strNews)
$strNews[$i] = Trim($strNews[$i])
Next
If $strNews[0] <> ""
$objSelection.Font.Bold = "1" ;1 = True, 0 = False.
$objSelection.Font.Color = "26367"
$objSelection.Font.Size = "10"
$objSelection.TypeText("News:")
$objSelection.Font.Size = "9"
$objSelection.Font.Bold = "0" ;1 = True, 0 = False.
$objSelection.TypeText(Chr(11))
For $i = 0 to UBound($strNews)
$objSelection.Font.Color = "8421504"
$objSelection.TypeText($strNews[$i])
$objSelection.TypeText(Chr(11))
Next
EndIf
EndIf
;Set extra text for the CallCenter
If $strDepartment = "CallCenter"
$objSelection.Font.Bold = "1" ;1 = True, 0 = False.
$objSelection.Font.Color = "26367"
$objSelection.TypeText("Title:")
$objSelection.Font.Bold = "0" ;1 = True, 0 = False.
$objSelection.TypeText(Chr(11))
$objSelection.Font.Color = "8421504"
$objSelection.TypeText($strPhonetxtnl)
EndIf
$objSelection = $objDoc.Range()
;Add signature and set outlook to use the signature.
$objSignature=$objSignatureEntries.Add(@FULLNAME + " NL", $objSelection)
$objSignatureObject.NewMessageSignature = @FULLNAME + " NL"
;$objSignatureObject.NewMessageSignature = ""
;$objSignatureObject.ReplyMessageSignature = @FULLNAME + " NL"
$objSignatureObject.ReplyMessageSignature = ""
;Quit word
$objDoc.Saved = 1
$objWord.Quit
;endregion