none
Best way to do a simplified advanced search? RRS feed

  • Question

  • One of the tasks our exchange users need to do is search by one of the user fields, and presently in Outlooks advanced search they would need to specifically find where User Field 2 contains a group value.  (ie.  search all contacts where user field 2 contains "B-O" and user field 2 contents may appear as "Andover; B-O; XMAS-O" where the semicolons join together multiple groups, and also search for valid or specific email address patterns as well?

    While it appears that Outlook's advanced search cannot be customizable for such non-technical users, would it be possible through perhaps a form region, add-in or VSTO c# programming to have such a form to enable advanced searches without searching and finding such miscellaneous fields the users can forget each time?

    Thursday, November 1, 2012 4:09 PM

Answers

All replies

  • You can execute a search in the current Explorer using Explorer.Search(Query, SearchScope).


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, November 1, 2012 5:03 PM
  • So if I understand correctly, I can develop a VSTO C# windows application that can prompt for the custom fields, then have a button they can press and it will invoke the Explorer.Search method?
    Thursday, November 1, 2012 5:14 PM
  • Correct. Or you can do it from a COM add-in.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Thursday, November 1, 2012 6:27 PM
  • At the moment I'm trying to find an example such that where my windows form allows the user to enter the fields they want to perform an advanced search on and then press the button.  I can't seem to find an online example of how to use the Explorer.Search method.

    So far I can at least determine my contact folder using the following code examples:

                    if (apf.Length > 0)   // if apf is set to "All Public Folders" or not
                    {
                        rolodexItems = oFolders[mainFldr].Folders[apf].Folders[subFldr].Items;
                    }
                    else
                    {
                        rolodexItems = oFolders[mainFldr].Folders[subFldr].Items;
                    }

    Also, any syntax example of how the query string is built?  I would guess something along the lines of Item.user2 == "B-O" at least.

    Monday, November 5, 2012 7:43 PM
  • See http://msdn.microsoft.com/en-us/library/office/bb220302(v=office.12).aspx

    You can experiement with the search in the Outlook UI. The query below, for example, will search fro subject and a custom property named "TestProp"

    subject:(test subject) [TestProp]:(test)


    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Tuesday, November 6, 2012 11:22 PM
  • I can at least do the following example in the UI:

    LastName:Smith FirstName:John: Company:Acc

    I notice when I change "Smith" to "mit" for a contains search it does not seem to work.  Any alternative way to accomplish this?

    Wednesday, November 7, 2012 6:27 PM
  • I don't think you can do that: for subject, it uses "contains". For LastName, Outlook uses "starts with"

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Wednesday, November 7, 2012 6:39 PM
  • How about Application.AdvancedSearch ?
    Wednesday, November 7, 2012 6:43 PM
  • It will give you a search object that will be visible only if you call Save - you will then get a search folder.

    Dmitry Streblechenko (MVP)
    http://www.dimastr.com/redemption
    Redemption - what the Outlook
    Object Model should have been
    Version 5.4 is now available!

    Sunday, November 11, 2012 6:28 PM