none
C# vsto outlook how to get the addresslist of SelectNamesDialog result "Check Name" RRS feed

  • Question

  • hi, I am trying to get search for a list of my company meeting rooms status before start to create a meeting.

    with this vsto addin, I used below code to achieve that:

     Outlook.SelectNamesDialog oSnd = Globals.ThisAddIn.Application.Session.GetSelectNamesDialog();            
    oSnd.SetDefaultDisplayMode(Outlook.OlDefaultSelectNamesDisplayMode.olDefaultPickRooms);
    Outlook.Recipient rec_room = oSnd.Recipients.Add("Company Name");
    rec_room.Type = (int)Outlook.OlMeetingRecipientType.olResource;
    
    
    oSnd.Recipients.ResolveAll();
    oSnd.Display();

    it worked, but I want to get the whole list of these available rooms.

    it showed the cases like below:

    anybody know how to get that?

    Monday, December 24, 2018 8:14 AM

Answers

  • On the Extended MAPI level (C++ or Delphi only) you can create a PR_ANR restriction on the contents table of a particular search container (such as GAL). That is what Outlook does when it resolves a name you typed in the To edit box - it goes through all containers in the search path and applies the PR_ANR restriction. If there are multiple matches found, it displays a dialog box with the list. If there is a single match, it is returned and the search is stopped, otherwise it continues to the next container in the search path.

    Outlook Object Model however does not expose this functionality. If using Redemption (any language) is an option, it exposes RDOAddressBook.ResolveNameEx and RDOAddressList.ResolveNameEx, which return a list of matches.

      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set AdrrEntries = Session.AddressBook.ResolveNameEx("john")
      Debug.Print AdrrEntries.Count & " names were retruned by ResolveNameEx:"
      Debug.Print "------------"
      for each AE in AdrrEntries
        Debug.Print AE.Name
      next
      Debug.Print "------------"
    <time datetime="2016-02-05T13:20:41" itemprop="dateCreated"></time>s

    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 lemontea199 Wednesday, March 13, 2019 12:23 PM
    Wednesday, December 26, 2018 1:24 AM

All replies

  • On the Extended MAPI level (C++ or Delphi only) you can create a PR_ANR restriction on the contents table of a particular search container (such as GAL). That is what Outlook does when it resolves a name you typed in the To edit box - it goes through all containers in the search path and applies the PR_ANR restriction. If there are multiple matches found, it displays a dialog box with the list. If there is a single match, it is returned and the search is stopped, otherwise it continues to the next container in the search path.

    Outlook Object Model however does not expose this functionality. If using Redemption (any language) is an option, it exposes RDOAddressBook.ResolveNameEx and RDOAddressList.ResolveNameEx, which return a list of matches.

      set Session = CreateObject("Redemption.RDOSession")
      Session.MAPIOBJECT = Application.Session.MAPIOBJECT
      set AdrrEntries = Session.AddressBook.ResolveNameEx("john")
      Debug.Print AdrrEntries.Count & " names were retruned by ResolveNameEx:"
      Debug.Print "------------"
      for each AE in AdrrEntries
        Debug.Print AE.Name
      next
      Debug.Print "------------"
    <time datetime="2016-02-05T13:20:41" itemprop="dateCreated"></time>s

    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 lemontea199 Wednesday, March 13, 2019 12:23 PM
    Wednesday, December 26, 2018 1:24 AM
  • worked quite well
    Wednesday, March 13, 2019 12:24 PM