myteam Posted July 9, 2010 Author Posted July 9, 2010 (edited) WOW!!! you really are something!! It work!!Now need to figure out how to check whether the address is label or textbox and execute the command depend on the type.Then skip the "State: " and only capture the value after that which the character can increase depend on the address. (I think I will go with StringStripWS + StringSplit , ":")Really need to know how to check whether the textbox/label exist in the form. i think it something like thisI try with this code but got error since "= Nothing" is wrong syntax for Autoit $Findlabel = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label5") If NOT $Findlabel = Nothing Then MsgBox(0, "", "Got Label!") Else MsgBox(0, "", "No Label!") Endif Edited July 10, 2010 by myteam
myteam Posted July 10, 2010 Author Posted July 10, 2010 I think I need to use loop + autoit error handling for this thing. But don't understand the example in help file nor in outlook udf to code them.
water Posted July 10, 2010 Posted July 10, 2010 This code snippet should handle the problem with non existing controls: Global $oMyError = ObjEvent("AutoIt.Error", "_MyErrorHandler") ; Install a custom error handler Global $iCOMError = 0 $oOutlook = ObjCreate("Outlook.Application") $oNewItem = $oOutlook.CreateItemFromTemplate("H:\tools\AutoIt3\SADMG\SADMG AID Project\SADMG.oft") $sLabelCaption = $oNewItem.GetInspector.ModifiedFormPages("Message" ).Controls("Label28" ).caption If $iCOMError = 1 Then MsgBox(0,"","Element could not be found") Else MsgBox(0,"","Element was found") EndIf Func _MyErrorHandler() $iCOMError = 0 Local $bHexNumber = Hex($oMyError.number, 8) Local $sError = "COM Error Encountered in " & @ScriptName & @CRLF & _ "Scriptline = " & $oMyError.scriptline & @CRLF & _ "NumberHex = " & $bHexNumber & @CRLF & _ "Number = " & $oMyError.number & @CRLF & _ "WinDescription = " & StringStripWS($oMyError.WinDescription, 2) & @CRLF & _ "Description = " & StringStripWS($oMyError.description, 2) & @CRLF & _ "Source = " & $oMyError.Source & @CRLF & _ "HelpFile = " & $oMyError.HelpFile & @CRLF & _ "HelpContext = " & $oMyError.HelpContext & @CRLF & _ "LastDllError = " & $oMyError.LastDllError Switch $bHexNumber Case "80020009" $iCOMError = 1 Case Else MsgBox(262144, "My COM Error handler", $sError) EndSwitch EndFunc ;==>_MyErrorHandler If a control does not exist error "80020009" is raised. All COM errors are handled function _MyErrorHandler. For error "80020009" the error handler sets the variable $iCOMError = 1 and returns to the calling script line. You now can check for the absence of a control. All other COM errors are displayed in a MSGBox. My UDFs and Tutorials: Reveal hidden contents 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
myteam Posted July 10, 2010 Author Posted July 10, 2010 It work great!!! Thank you very much for your kind guidance.
water Posted July 11, 2010 Posted July 11, 2010 (edited) Or even better:$oOutlook = ObjCreate("Outlook.Application") $oNewItem = $oOutlook.CreateItemFromTemplate("H:\tools\AutoIt3\SADMG\SADMG AID Project\SADMG.oft") $oControl = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label28") If IsObj($oControl) Then MsgBox(0,"","Exists. Caption is " & $oControl.caption) Else MsgBox(0,"","Does not exist") EndIfBased on this Newsgroup. Edited July 11, 2010 by water My UDFs and Tutorials: Reveal hidden contents 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
myteam Posted July 11, 2010 Author Posted July 11, 2010 (edited) $oControl = $oNewItem.GetInspector.ModifiedFormPages("Message").Controls("Label28") Nope, it not working since the program will crash in this line because it point to non-existence control. By the way, I seem to have problem with stringsplit. If the code is like this: $aMail = StringSplit("water@google.com;myteam@yahoo.com",";") I can have the result to show = water@google.com But, sometimes there is only 1 email without the ";". That's when my script crash. Example: $aMail = StringSplit("water@google.com",";") = CRASH How can I check if the email contain ";"? Do I need to use Autoit error handling just like checking the label? p/s: I feel bad using error handling to make my buggy script work Edited July 11, 2010 by myteam
water Posted July 12, 2010 Posted July 12, 2010 Quote Nope, it not working since the program will crash in this line because it point to non-existence control.You are right. You need the Errorhandler stuff to check for the existance of a control. Quote By the way, I seem to have problem with stringsplit.Stringsplit, like any other AutoIt function, sets @error in case of a problem.So please check the helpfile and you'll find a returncode for "no ; in the string". In this case simply use the original string as mail address. My UDFs and Tutorials: Reveal hidden contents 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
myteam Posted July 12, 2010 Author Posted July 12, 2010 @error trick work!! Thank you very much Water!! I'm planning to do next automation project later using excel as the source after finish fixing up all the bug in my script. Hope you will be there!! Autoit is awesome!!! p/s: You maybe not Outlook Guru but you are Master!
water Posted July 13, 2010 Posted July 13, 2010 Quote I'm planning to do next automation project later using excel as the source afterfinish fixing up all the bug in my script. Hope you will be there!!Excel is quite easy. You can use the builtin Excel UDF or - if you need more functions - use the ExcelCOM UDF or code everything yourself. Quote p/s: You maybe not Outlook Guru but you are Master! Thanks! I'm glad it works! My UDFs and Tutorials: Reveal hidden contents 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