Search code examples
outlookoutlook-redemption

Querying "field" in Outlook RDOMail object


I have a piece of code that uses DASL queries to query values saved in the user property of items in an RDOFolder, something like this: rdoFolder.Items.Find("\"http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/MyUserPropertyName/0x0000001F\"='queryValue'" However, now I need to migrate data saved in my user properties into the Field property of RDOMail item. I'd like to know if there's a similar way to query this Field property for fast performance. Looping through all items in the folder to do a value comparison could be very slow when there are tens of thousands of items.


Solution

  • I found that the RDOFolder.Items.Find method also searches values saved via the RDOMail.Fields index property. Just as what Dmitry said in his comment.

    For example, if I set the value like this:

    myRdoMail.Fields["http://schemas.microsoft.com/mapi/string/{8d736f90-8f45-4591-81aa-c85a98f1261b}/MyUserProperty"] = "MyValue";
    

    Then I'll be able to find this item by doing the following:

    var result = myRdoFolder.Items.Find("\"http://schemas.microsoft.com/mapi/string/{8d736f90-8f45-4591-81aa-c85a98f1261b}/MyUserProperty\"='MyValue'");