none
Address book Provider implementation using C# RRS feed

  • Question

  • Hi,

    I want to create Address Book Provider and Check Names Dialog box which is available in Outlook. Is there any possibility to create those dialogs alone using windows API's?

    Just i want to place one text box and button. When i click button it should launch Check names dialog box.

    Please help me out.

    Thanks,

    Thursday, May 15, 2014 7:15 AM

All replies

  • Hello Elangovan,

    See IAddrBook::ResolveName . If you pass the MAPI_DIALOG value as the second parameter the dialog will be shown.

    Thursday, May 15, 2014 7:30 AM
  • Address book provider can only be implemented in C++ or Delphi.

    What exactly are you trying to do? Display the ambiguous Name dialog?


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

    Thursday, May 15, 2014 5:11 PM
  • I want to implement "Address provider" dialog using C#.

    Is it possible???

    Saturday, May 17, 2014 5:46 AM
  • You can try to use the SelectNamesDialog dialog. It displays the Select Names dialog box for the user to select entries from one or more address lists, and returns the selected entries in the collection object specified by the property SelectNamesDialog.Recipients. Here is what MSDN states:

    You can instantiate an instance of the SelectNamesDialog object by calling NameSpace.GetSelectNamesDialog.

    The dialog box displayed by SelectNamesDialog.Display is similar to the Select Names dialog box in the Outlook user interface. It observes the size and position settings of the built-in Select Names dialog box. However, its default state does not show Message Recipients above the To, Cc, and Bcc edit boxes. For more information on using the SelectNamesDialog object to   display the Select Names dialog box, see Display Names from the Address Book.

    You can read more about the dialog in the Display Names from the Address Book article in MSDN. Also you may find the How to: Display a Dialog Box for Selecting Entries from the Contacts Folder article helpful.

    Sub ShowContactsInDialog() 
     Dim oDialog As SelectNamesDialog 
     Dim oAL As AddressList 
     Dim oContacts As Folder 
     
     Set oDialog = Application.Session.GetSelectNamesDialog 
     Set oContacts = _ 
     Application.Session.GetDefaultFolder(olFolderContacts) 
     
     'Look for the address list that corresponds with the Contacts folder 
     For Each oAL In Application.Session.AddressLists 
     If oAL.GetContactsFolder = oContacts Then 
     Exit For 
     End If 
     Next 
     With oDialog 
     'Initialize the dialog box with the address list representing the Contacts folder 
     .InitialAddressList = oAL 
     .ShowOnlyInitialAddressList = True 
     If .Display Then 
     'Recipients Resolved 
     'Access Recipients using oDialog.Recipients 
     End If 
     End With 
    End Sub

    P.S.  You are free to use the SelectNamesDialog dialog in C#.
    Saturday, May 17, 2014 6:27 AM
  • What "address provider" dialog? Do you mean ambiguous name resolution dialog?

    What exactly are you trying to do and why?


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

    Saturday, May 17, 2014 9:12 PM
  • Thank you..

    I can able to launch Address book dialog using above code. The same way i want to launch "Check names" dialog.

    Please guide me.


    Tuesday, May 20, 2014 6:31 AM
  • Outlook Object Model does not expose that dialog. If using Redemption is an option, the following code will show that dialog:

    set Session = CreateObject("Redemption.RDOSession")
    Session.MAPIOBJECT = Application.Session.MAPIOBJECT
    Session.ParentWindow = Application.ActiveWindow
    set user = Session.AddressBook.ResolveName("dummy name to resolve", true)


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

    Tuesday, May 20, 2014 6:40 AM
  • Hi,

    thanks for your reply. But i want to implement "Check names" dialog using C#. is it possible?

    Wednesday, May 21, 2014 4:32 AM
  • RDOSession session = new RDOSession(); Session.MAPIOBJECT = Application.Session.MAPIOBJECT; Session.ParentWindow = Application.ActiveWindow; RDOAddressEntry user = Session.AddressBook.ResolveName("dummy name to resolve", true);

    You can do that using Redemption. The script above can be converted to C# (off the top of my head):


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

    Wednesday, May 21, 2014 4:47 AM
  • ok thank you. I will try this.

    And I have another issue while implementing "Address book provider". I used below code to implement that.

                Outlook.Application oApp = new Outlook.Application();
                Outlook.SelectNamesDialog snd = oApp.Session.GetSelectNamesDialog();
                snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowToCc;
                snd.Display();

    Using the above code it is displaying Address book dialog.

    But most of the times, this dialog is launching from Outlook only. I can't create standalone dialog. It is like a domodal dialog for outlook. I want to create separate address book dialog without any dependency on outlook..

    Can anyone guide me on this??

    Thanks

    Wednesday, May 21, 2014 11:04 AM
  • Hello Elangovan,

    You can read more about the SelectNamesDialog dialog in MSDN. See Display Names from the Address Book for more information.

    You can develop your own windows form with custom controls if you want to use such dialog outside of Outlook. Note, you can use the Outlook object model for populating the dialog with address book entries. Does it make any sense?

    Wednesday, May 21, 2014 12:31 PM
  • Hi,

    I referred those links. My problem is,

    For example,

    I have created one application with one address button. And whenever i click address button it will launch address dialog using the above mentioned code. The code is working properly if outlook is not opened. If outlook is in open, If i click address button it is not launching address dialog from my screen. Instead Outlook is blinking in the task bar and address dialog is opened in outlook. I can't close the outlook application since the address dialog is domodal for outlook application.

    Actual expected behaviour is it should not launch from outlook. If i click address button from my application then it should launch address dialog from my screen. not from outlook.

    Code is:

                Outlook.Application oApp = new Outlook.Application();
                Outlook.SelectNamesDialog snd = oApp.Session.GetSelectNamesDialog();
                snd.NumberOfRecipientSelectors = Outlook.OlRecipientSelectors.olShowToCc;
                snd.Display();

    Thanks.

    Wednesday, May 21, 2014 1:23 PM
  • In that case you need to develop your own windows form and display data there. There is no other way to get your task done.
    Wednesday, May 21, 2014 2:17 PM
  • When you are using the Outlook Object Model, all calls are marshaled into the outlook.exe address space and Outlook does not know whether the call is being made from a COM addin / VBA code inside Outlook or an external app.

    You would need to be able to provide the parent window handle to be used by MAPI when displaying the address book dialog, which Outlook Object Model does not expose.

    Again, your options are Extended MAPI in C++ or Delphi or Redemption and its RDOSession.Addressbook.ShowAddressBook and RDOSession.GetSelectNamesDialog- they both allow to pass the parent window handle and use the topmost window if none is expliiclty specified.


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


    Wednesday, May 21, 2014 2:27 PM
  • I don't know how to include reference for RDOSession. Please help me.
    Thursday, May 22, 2014 7:30 AM
  • Download Redemption, install the dll with the appropriate bitness (redemption.dll or redemption64.dll) using regsvr32.exe

    Add a reference to Redemption either from the COM tab of the References dialog or add a reference to the included interop dll (Interop.Redemption.dll).


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

    Thursday, May 22, 2014 1:35 PM
  • Hi,

    Thanks. I can launch the standalone dialog using "redemption.dll". I Just downloaded the dll and register using regsvr32. I added reference of redemption.dll.

    I want to associate this dialog into my application.

    can i use directly this dll? is it free of cost?

    thanks

    Saturday, May 24, 2014 4:01 PM