Before performing a search on the calendar folder, I want to test if the
user property "test" exists in any of its items because if I don't test it,
an exception is raised.
Thank you
Rémi
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm
"Rémi" <R...@discussions.microsoft.com> wrote in message
news:0D7721DF-8B57-4222...@microsoft.com...
If you're in any doubt about whether a property is present in the folder, perhaps the easiest course of action is simply to add the to the folder: Create a PostItem in the folder, use PostItem.UserProperties.Add to add the property, then discard the PostItem.
--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003
http://www.turtleflock.com/olconfig/index.htm
and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
http://www.outlookcode.com/jumpstart.aspx
"Rémi" <R...@discussions.microsoft.com> wrote in message news:0D7721DF-8B57-4222...@microsoft.com...
I don't think you understand yet at all. It is very easy to test whether a user property exists on an individual ***item*** -- just try to return it from the UserProperties collection. What is not easy to tell is whether the property is defined at the ***folder*** level, which is a prerequisite for being able to search on it programmatically.
> But the problem is that I don't understand why you are creating a PostItem
> and then discard it ? Is it in order to avoid getting an exception when
> trying to search on the user property ?
You discard it because you don't need it. The whole purpose of creating the item in the folder is to be able to set a custom property definition at the folder level, by adding the property to an item that you know exists in that folder.
I think I'll use the try/catch method. It seems me easier.