How to use Application.AdvancedSearch() with a custom user property type?

Add-in Express™ Support Service
That's what is more important than anything else

How to use Application.AdvancedSearch() with a custom user property type?
 
Jonathan Gilpin




Posts: 50
Joined: 2012-12-11
I'm creating a user property with the code below. The mail item is from the 'Inbox' folder.

I would like to know how to create a Search object, from Application.AdvancedSearch();

The main problem I'm having is what the DASL search filter should be.

My guess is something like this...

string MyCustomField = addQuotes("http:/schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/IsValid/0x0000000B");
(note: I could not put http and two // , add-in express's forum filters that out)

but Application.AdvancedSearch() still throws an error.

My goal is to use the returned Search object..and call Save() to create a new Search Folder , based on my custom user property.

Any help is greatly appreciated!

Jon


mailUserProperties = mailItem.UserProperties;
property = mailUserProperties.Add("IsValid", OlUserPropertyType.olYesNo, true, OlFormatYesNo.olFormatYesNoIcon);
property.Value = true;
item.Save();
Posted 19 Mar, 2013 18:55:30 Top
Andrei Smolin


Add-in Express team


Posts: 19029
Joined: 2006-05-11
Hello Jonathan,

In Inbox, choose View | View Settings | Filter | Advanced, find your UserProperty in the Field dropdown, specify a condiftion and add it to the list, then switch to the tab SQL and find the filter string. Below is a VBA macro which works for me:

Dim strFilter As String
strFilter = """http:/schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/myUserProperty"" LIKE '%myString%'"

Dim strScope As String
strScope = "Inbox"

Dim srch As Outlook.Search
Set srch = Application.AdvancedSearch(strScope, strFilter, False, "MyTag")



Andrei Smolin
Add-in Express Team Leader
Posted 20 Mar, 2013 10:32:11 Top
Jonathan Gilpin




Posts: 50
Joined: 2012-12-11
Thanks Andrei!

It looks like 0x0000000B was my problem. Even though I read the schema should include the type at the end on MSDN..but I guess not in this case!

Jon
Posted 20 Mar, 2013 16:37:45 Top