I want to be able to search from the ribbon in my Add in, but when I construct a query based on the conversationID and attempt to run an advanced search I get the same exception every time:
System.Runtime.InteropServices.COMException: 'The operation failed.'
The code looks something like the following:
private async void inSearchId_TextChanged(object sender, RibbonControlEventArgs e)
{
var searchText = (sender as RibbonEditBox).Text;
if (searchText.Length < 5) return; // No point searching until theres a decent query to search against
var conversationLinks = await GetConversationsBySearch(searchText);
var filter = BuildFilterFromConversationIds(conversationLinks);
Search search = _app.AdvancedSearch("inbox", filter, true, "CustomQuery");
search.Results.Sort("[ReceivedTime]", OlSortOrder.olDescending);
}
The return value of BuildFilterFromConversationIds is
@SQL="http://schemas.microsoft.com/mapi/proptag/0x3013001E" = '22E6722D04D84704B28B060C1CA5AB92'
Or in another iteration:
@SQL="urn:schemas:httpmail:conversationid" = '22E6722D04D84704B28B060C1CA5AB92'
Both of which throw the above error.
I am able to get it to work (as a test) with the following query:
urn:schemas:httpmail:subject LIKE '%Test%'
I've looked in a lot of places, but I can't see what it is that I'm missing. What should the query look like to search by conversation ID? And why is it throwing the exception?
PR_CONVERSATION_IDproperty is0x30130102(note that the type isPT_BINARY=0x0102), not0x3013001E(type isPT_STRING8=0x001E).But OOM would not let you search on binary (
PT_BINARY) properties. If using Redemption is an option (I am its author), it does allow binary searches. Off the top of my head: