none
Using AdvancedSearch on an address list RRS feed

  • Question

  • C# VS 2017

    I would like to do an AdvancedSearch on the global address list. However finding the correct syntax for the filter is proving to be difficult.

    Given that I have:

    Outlook.Application app=<my outlook app>;
    Outlook.AddressList addrList =<the address list I want search>

    and that I've already set app.AdvancedSearchComplete to my event handler.

    Best I can tell I use app.AdvancedSearch("An inconsequential string", "A filter whose syntax I'm not sure of", addrList, "Another string whose purpose is not clearly defined");

    I would very much appreciate some help. I've tried manually iterating through the list with a foreach loop and if the name is near the end it takes multiple minutes.

    TIA,

    Nottoc

    Thursday, June 7, 2018 7:45 PM

Answers

  • AdvancedSearch only operates on the message stores. It does not work at all on address book lists.

    As a side note, while message stores support very complex searches, the address book providers do not - Outlook simply does not utilize such capabilities.  On the Extended MAPI level, the only search supported by all address book providers is the PR_ANR restriction used by Outlook when displaying the list of the ambiguous names when a name cannot be resolved. GAL also support PR_SEARCH property (it can be opened as IMAPIContainer).

    On the Outlook Object Model level, the best you can do is Namespace.CreateRecipient / Recipient.Resolve. You cannot use arbitrary search criteria, and you cannot get back multiple entries if the specified name is ambiguous.

    If using Redemption is an option, it supports RDOSession.Addressbook.ResolveName (similar to Namespace.CreateRecipient in OOM), RDOSession.Addressbook.ResolveNameEx (it returns a list of multiple matches using PR_ANR search), and RDOAddressList.ResolveName / ResolveNameEx / Search. The last one (RDOSearch) uses GAL specific PR_SEARCH capability).


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

    • Marked as answer by nottoc Thursday, June 7, 2018 9:08 PM
    Thursday, June 7, 2018 8:15 PM

All replies

  • AdvancedSearch only operates on the message stores. It does not work at all on address book lists.

    As a side note, while message stores support very complex searches, the address book providers do not - Outlook simply does not utilize such capabilities.  On the Extended MAPI level, the only search supported by all address book providers is the PR_ANR restriction used by Outlook when displaying the list of the ambiguous names when a name cannot be resolved. GAL also support PR_SEARCH property (it can be opened as IMAPIContainer).

    On the Outlook Object Model level, the best you can do is Namespace.CreateRecipient / Recipient.Resolve. You cannot use arbitrary search criteria, and you cannot get back multiple entries if the specified name is ambiguous.

    If using Redemption is an option, it supports RDOSession.Addressbook.ResolveName (similar to Namespace.CreateRecipient in OOM), RDOSession.Addressbook.ResolveNameEx (it returns a list of multiple matches using PR_ANR search), and RDOAddressList.ResolveName / ResolveNameEx / Search. The last one (RDOSearch) uses GAL specific PR_SEARCH capability).


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

    • Marked as answer by nottoc Thursday, June 7, 2018 9:08 PM
    Thursday, June 7, 2018 8:15 PM
  • That will be sufficient since my plan was to do validation against the address list and I don't really need multiple results with an ambiguous entry.

    However, it does make me wonder if there's an undocumented interface since I can quickly, within outlook, get multiple results on an address book search. And there is an "Advanced Find" on the address search dialog. Things that make a person go hmmm.

    Thursday, June 7, 2018 9:08 PM
  • Advanced Search can search through your contacts (which are messages with the message class of IPM.Contact). This is not address book, it just happens to be what OAB provider uses as its storage.

    "Find" in the address book dialog uses PR_SEARCH that I described above.


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

    Thursday, June 7, 2018 9:20 PM