water Posted December 12, 2010 Share Posted December 12, 2010 Hi, I try to acces the properties of an Outlook item (contact, address ...) by name. $Result = $oItem.ItemProperties.Item("FirstName").value If the property doesn't exist I get H:\tools\AutoIt3\Outlook\OutlookGetItems.au3 (197) : ==> Object referenced outside a "With" statement.: $Result = $oItem.ItemProperties.Item("xy").value $Result = $oItem.ItemProperties.Item("xy").^ EROR How can I check if a property exists? Thanks in advance! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 12, 2010 Share Posted December 12, 2010 Maybe get the collection of .ItemProperties then walk the collection checking for $oProperty.name: $oItemProperties = $oItem.ItemProperties $f_Found = False For $oProperty In $oItemProperties If $oProperty.name & "" = "firstName" Then $f_Found = True ExitLoop EndIf Next If $f_Found Then MsgBox(64, "Found", "Item property 'FirstName' = " & $oItem.ItemProperties.Item("FirstName" ).value) Else MsgBox(16, "Not Found", "Item does not have 'FirstName' property.") EndIf (Not tested.) Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
water Posted December 13, 2010 Author Share Posted December 13, 2010 Hi PsaltyDS, thanks for the fast reply! I had something similar in mind (and have already implemented it). But I was dreaming of a "one-liner" to test for existance or at least a way to catch the error if a property that doesn't exist is accessed. Thanks and greetings from snowy Austria! My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
PsaltyDS Posted December 13, 2010 Share Posted December 13, 2010 Well, if you have a COM error handler implemented (and I KNOW you do) this should work in two lines without crashing the script on error: $oTarget = $oItem.ItemProperties.Item("xy") If IsObj($oTarget) Then $Result = $oTarget.value Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law Link to comment Share on other sites More sharing options...
water Posted December 14, 2010 Author Share Posted December 14, 2010 Hi PsaltyDS, thanks for your suggestion. I will give it a try. My UDFs and Tutorials: Spoiler UDFs:Active Directory (NEW 2022-02-19 - Version 1.6.1.0) - Download - General Help & Support - Example Scripts - WikiExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example ScriptsOutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - WikiOutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - DownloadOutlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - WikiPowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - WikiTask Scheduler (NEW 2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki Standard UDFs:Excel - Example Scripts - WikiWord - Wiki Tutorials:ADO - WikiWebDriver - Wiki Link to comment Share on other sites More sharing options...
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