简体   繁体   中英

Using Microsoft.Office.Interop.Outlook without Outlook Client installed

I'm trying to enumerate Outlook Global Address List and I don't have Outlook Client installed on a development server. I'm getting following error

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in mscorlib.dll

Additional information: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).

on the following line

Application app = new Microsoft.Office.Interop.Outlook.Application();

I assume it's because Outlook Client is not installed. Is it possible to use Microsoft.Office.Interop.Outlook without it?

Anton,

I assume it's because Outlook Client is not installed. Is it possible to use Microsoft.Office.Interop.Outlook without it?

Interop files are used for marshalling calls between managed/unmanaged boundaries. There is no the unmananged side in your case (where to marshal the call).

As already was suggested, you can use EWS instead. See EWS Managed API, EWS, and web services in Exchange for more information.

I don't have Outlook Client installed on a development server.

Moreover, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment .

If you are building a solution that runs in a server-side context, you should try to use components that have been made safe for unattended execution. Or, you should try to find alternatives that allow at least part of the code to run client-side. If you use an Office application from a server-side solution, the application will lack many of the necessary capabilities to run successfully. Additionally, you will be taking risks with the stability of your overall solution.

You can read more about that in the Considerations for server-side Automation of Office article.

It is not possible to use the Interop assemblies without its associated application installed where you need to use it. The Interop assemblies are used primarily as an advanced application automation system.

If you are using Exchange Server 2007 or later, you could consider using the technique described in this article which uses Exchange Web Services (EWS) to access the Global Address List instead: Querying the Global Address List (GAL) via Exchange Web Services (EWS)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM