1

我开发了一个内网应用程序,其中一个下拉列表与 Outlook 的全局地址列表数据绑定。代码如下所示:

字典列表 = 新字典();// 创建 Outlook 应用程序。Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application();

        // Get the NameSpace information.
        Microsoft.Office.Interop.Outlook.NameSpace oNS = oApp.GetNamespace("mapi");


       // oNS.Logon(oNS.CurrentProfileName, "*********", true, true);


        // Get the default Contacts folder.
        Microsoft.Office.Interop.Outlook.MAPIFolder oContacts = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderContacts);
      //  Microsoft.Office.Interop.Outlook.AddressLists = oNS.AddressLists;
        // Get the Items collection from the folder.
        Microsoft.Office.Interop.Outlook.Items oItems = (Microsoft.Office.Interop.Outlook.Items)oContacts.Items;
        Microsoft.Office.Interop.Outlook.ContactItem oCt = (Microsoft.Office.Interop.Outlook.ContactItem)oItems.GetFirst();


        Microsoft.Office.Interop.Outlook.AddressLists addressbook=oNS.AddressLists;
        Microsoft.Office.Interop.Outlook.AddressList addrList = oNS.GetGlobalAddressList();
        foreach (Microsoft.Office.Interop.Outlook.AddressEntry addentry in addrList.AddressEntries)
        {

            Microsoft.Office.Interop.Outlook.ExchangeUser contact = addentry.GetExchangeUser();
            if(contact!=null)
                list.Add(contact.PrimarySmtpAddress, addentry.Name);
            //   string email = contact.Email1Address;
        }
        ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataSource = list;
        ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataTextField = "Key";
        ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataValueField = "Value";

        ((DropDownList)CreateUserWizard1.CreateUserStep.ContentTemplateContainer.FindControl("Email")).DataBind();

    }
    catch (System.Exception ex)
    {

    }  

该代码在开发系统中运行良好,但在服务器中出现 System.Runtime.InteropServices.COMException (0x80010001) 错误:检索具有 CLSID {0006F03A-0000-0000-C000-000000000046} 的组件的 COM 类工厂失败,原因如下错误:80010001。

Outlook 已安装并配置到电子邮件帐户。

请帮助解决问题:

4

2 回答 2

0

您是否在运行 Intranet 应用程序的服务器上安装了 Outlook?如果这样做,请确保 Outlook 组件在该计算机上具有正确的权限。

于 2013-06-18T12:19:05.773 回答
-1

一种行之有效的方法,

try { outlook = new Outlook.Application(); }
catch { outlook = new Outlook.Application(); }
于 2014-12-09T09:18:01.447 回答