解决Microsoft Outlook中多个邮箱中的联系人冲突

时间:2015-05-01 08:23:24

标签: c# outlook

我正在尝试解决Outlook 2010中模糊的联系人。我的Outlook配置了两个不同的邮箱,例如XXX@domain1.com和XXX@domain2.com。如果两个域中都存在特定用户(例如XXX),则Outlook会从默认地址簿中解析该名称。如何切换到其他地址簿(i,.e domain2)并解决?但是,如果domain1(i,默认值)中的联系人不存在,我的程序可以从domain2获取它。请建议我一种方法来解决特定域中的收件人。

我的应用程序在C#中,我使用的是Microsoft Outlook Library 14.0

3 个答案:

答案 0 :(得分:1)

如果使用Redemption是一个选项,则可以使用RDOAddressList。ResolveName方法来解析名称对特定GAL容器的影响。可以从RDOSession.AddressBookRDOExchangeAccount。GAL属性中检索RDOAddressList对象。可以从RDOSession.Accounts集合中检索RDOExchangeAccount。

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);

答案 1 :(得分:0)

Outlook对象模型不提供用于针对特定通讯簿解析收件人的任何属性或方法。对于“收件人”类,唯一可行的方法是ResolveResolveAll

答案 2 :(得分:0)

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;
    }