'Resolving contact conflict in more than one Mailbox in Microsoft Outlook

I am trying to resolve ambiguous contacts in Outlook 2010. My outlook is configured with two different mailboxes say [email protected] and [email protected]. If a particular user(say XXX) exist in both domains outlook resolves the name from the default address book. How to switch to the other address book (i,.e domain2) and resolve ? However if the contact doesn't exist in domain1(i,e default) my program can fetch it from domain2. Please suggest me a way to resolve recipient from a particular domain alone.

My application is in C# and i use Microsoft Outlook Library 14.0



Solution 1:[1]

If using Redemption is an option (I am its author), you can use RDOAddressList.ResolveName method to resolve a name against a particular GAL container. RDOAddressList object can be retrieved from either RDOSession.AddressBook or from RDOExchangeAccount.GAL property. RDOExchangeAccount can be retrieved from the RDOSession.Accounts collection.

VB:

  set Session = CreateObject("Redemption.RDOSession")
  Session.MAPIOBJECT = Application.Session.MAPIOBJECT
  set AddressEntry = Session.AddressBook.GAL.ResolveName("dmitry streblechenko")
  MsgBox AddressEntry.SMTPAddress

C#:

  Redemption.RDOSession session = new Redemption.RDOSession();
  session.MAPIOBJECT = Application.Session.MAPIOBJECT; //if you already have a pointer to the Outlook.Application object, Or call Logon
  Redemption.RDOAddressEntry addressEntry = session.AddressBook.GAL.ResolveName("dmitry streblechenko");
  MessageBox.Show(addressEntry.SMTPAddress);

Solution 2:[2]

The Outlook object model doesn't provide any property or method for resolving a recipient against a specific address book. The only possible method is Resolve or ResolveAll for the Recipients class.

Solution 3:[3]

   private Redemption.RDOAddressEntry ResolveRecipientsRDO(string name)
   {

        Redemption.RDOAddressEntry raddressEntry = null;
        try
        {  
            string displayName = (string)accountDisplayNames[domainSelect.Text];
            Microsoft.Office.Interop.Outlook.Application app = new Outlook.Application();
            Redemption.RDOSession session = new Redemption.RDOSession();
            session.MAPIOBJECT = app.Session.MAPIOBJECT;
            //if you already have a pointer to the Outlook.Application object, Or call Logon
            RDOStores stores = session.Stores;

            RDOAccounts accounts = session.Accounts;
          
            

            if (stores.DefaultStore.Name.ToLower().Equals(displayName.ToLower()))
            {
                WriteLog("Default account:" + stores.DefaultStore.Name.ToLower());
                // MessageBox.Show("Outlook's Default account name: " + stores.DefaultStore.Name.ToLower() + " matches with selected domain " + displayName);
                raddressEntry = session.AddressBook.ResolveName(name, true);

            }
            else
            {
                MessageBox.Show("The selected domain " + displayName + " is not Outlook's Default domain. Set this as default domain to resolve", "Default Mailbox Setting");
                accounts.DisplayAccountList();
                WriteLog("Default account:" + stores.DefaultStore.Name.ToLower());
                raddressEntry = session.AddressBook.ResolveName(name, true);

            }
        }
        catch(System.Exception e)
        {
            MessageBox.Show("Resolving error:" + e.GetBaseException());
            WriteLog("*******inside findAndWriteDirectReporteesintoPDF******");
        }
        
       
        return raddressEntry;
    }

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Eugene Astafiev
Solution 3 Dmitry Streblechenko