nappy Posted June 13, 2013 Posted June 13, 2013 Hi, I am trying to add a field in a signature script. I am currently referencing the mobile and fax field of a user in Active Directory I want to add the Home field as well but I keep getting a error "Windescription is: Variable must be type 'Object' "Error:Object referenced outside a "With" Statement. I am adding the line the same way I have done the other fields. What Am I doing wrong? Thanks
FireFox Posted June 13, 2013 Posted June 13, 2013 Hi, Welcome to the autoit forum Without your script, we need to guess what's wrong. Personally, I'm not this guy : . Br, FireFox.
FireFox Posted June 13, 2013 Posted June 13, 2013 (edited) Great, oh wait... need to put my glasses . Don't worry I'm waiting for your next post, simply use autoit code tags and paste your script inside . Edited June 13, 2013 by FireFox
nappy Posted June 13, 2013 Author Posted June 13, 2013 (edited) $SigPath = @AppDataDir & "MicrosoftAD" $SigPicPath = $SigPath & "signature.jpg" $adName = "" $adMail = "" $adJobDesc = "" $adHome = "" $adPhone = "" $adFax = "" $adMobile = "" $adPager = "" setOutlookSignature () activateSig () Func runSignatureScript () setOutlookSignature () activateSig () EndFunc Func setOutlookSignature () If not FileExists($SigPath) Then DirCreate ($SigPath) EndIf FileCopy(@LogonServer & "netlogonv1.0Softwaresignature.jpg", $SigPath, 1) createHTMLFile () EndFunc Func _ADLookup ($3LC) Local $objCommand = ObjCreate("ADODB.Command") Local $objConnection = ObjCreate("ADODB.Connection") $objConnection.Provider = "ADsDSOObject" $objConnection.Open("Active Directory Provider") $objCommand.ActiveConnection = $objConnection Local $strFilter = "(sAMAccountName=" & $3LC & ")" Local $strAttributes = "displayName, mail, title, Home, telephoneNumber, facsimileTelephoneNumber, mobile, pager" Local $strQuery = $strBase & ";" & $strFilter & ";" & $strAttributes & ";subtree" $objCommand.CommandText = $strQuery $objCommand.Properties("Page Size") = 100 $objCommand.Properties("Timeout") = 30 $objCommand.Properties("Cache Results") = False $ADS_SCOPE_SUBTREE = 2 $objCommand.Properties("searchscope") = $ADS_SCOPE_SUBTREE Local $objRecordSet = $objCommand.Execute While Not $objRecordSet.EOF $adName = $objRecordSet.Fields("displayName").value $adMail = $objRecordSet.Fields("mail").value $adJobDesc = $objRecordSet.Fields("title").value $adHome = $objRecordSet.Fields("home").value $adPhone = $objRecordSet.Fields("telephoneNumber").value $adFax = $objRecordSet.Fields("facsimileTelephoneNumber").value $adMobile = $objRecordSet.Fields("mobile").value $adPager = $objRecordSet.Fields("pager").value $objRecordSet.MoveNext WEnd $objConnection.Close $objConnection = "" $objCommand = "" $objRecordSet = "" $objRootDSE = "" Return "" EndFunc Func createHTMLFile () $none = _ADLookup (@UserName) If _ADIsMemberOf (_ADSamAccountNametoFQDN ("SCC Team (Staff Consultative Committee)"), _ADSamAccountNametoFQDN (@UserName)) Then SCCSignature (); EndIf ;MsgBox(0, "Tutorial", $adName & " " & $adMail & " " & @UserName) $file = FileOpen($SigPath & "mt.htm", 2) FileWriteLine ($file, "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">") FileWriteLine ($file, "<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>") FileWriteLine ($file, "<META http-equiv=Content-Type content=""text/html; charset=windows-1252"">") FileWriteLine ($file, "<META content=""MSHTML 6.00.3790.186"" name=GENERATOR></HEAD>") FileWriteLine ($file, "<body>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adName & " <br>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adJobDesc & " <br>") If $adHome <> "" Then FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adHome & " <br>") EndIf FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> Tel: " & $adPhone & " <br>") If $adFax <> "" Then FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> Fax: " & $adFax & " <br>") EndIf If $adMobile <> "" and $adPager = "none" Then FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> Cell: " & $adMobile & " <br>") EndIf FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> E-mail: <a href=mailto:" & $adMail & " >" & $adMail & "<br>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""><a href=http://www.google.com><font color=#000000>www.google.com</font></a> <br>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> <br>") FileWriteLine ($file, "</font></a></B>") FileWriteLine ($file, "</h6></font>") FileWriteLine ($file, "<font color=000000 face=Calibri><A href=http://www.google.com> <img width=""250px"" height=""60px"" src=signature.jpg ></a><br>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> <br>") FileWriteLine ($file, "<br>") FileWriteLine ($file, "</FONT></BODY></HTML>") FileClose($file) $file = FileOpen($SigPath & "reply.htm", 2) FileWriteLine ($file, "<!DOCTYPE HTML PUBLIC ""-//W3C//DTD HTML 4.0 Transitional//EN"">") FileWriteLine ($file, "<HTML><HEAD><TITLE>Microsoft Office Outlook Signature</TITLE>") FileWriteLine ($file, "<META http-equiv=Content-Type content=""text/html; charset=windows-1252"">") FileWriteLine ($file, "<META content=""MSHTML 6.00.3790.186"" name=GENERATOR></HEAD>") FileWriteLine ($file, "<body>") FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adName & " <br>") If $adMobile <> "" and $adPager = "none" Then FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adJobDesc & " | Mobile Telecommunications Ltd | Tel: " & $adPhone & " | Cell: " & $adMobile & " | Fax: " & $adFax & " | <a href=http://www.mtc.com.na><font color=#000000>www.mtc.com.na</font></a> <br>") Else FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> " & $adJobDesc & " | Mobile Telecommunications Ltd | Tel: " & $adPhone & " | Fax: " & $adFax & " | <a href=http://www.mtc.com.na><font color=#000000>www.mtc.com.na</font></a> <br>") EndIf FileWriteLine ($file, "<font style=""font-family:Calibri; font-size: 10pt; color=000000;""> <br>") FileWriteLine ($file, "<br>") FileWriteLine ($file, "</FONT></BODY></HTML>") FileClose($file) EndFunc Edited June 13, 2013 by nappy
water Posted June 13, 2013 Posted June 13, 2013 To access Active Directory I suggest do use my AD UDF. To create an Outlook signature use my OutlookEX UDF. My UDFs and Tutorials: Spoiler UDFs: Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs: Excel - Example Scripts - Wiki Word - Wiki Tutorials: ADO - Wiki WebDriver - Wiki
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now