Can one use the Outlook.Application.Explorer object in a standalone application?

c#, outlook

Solution

Yes, you can use Office integration in a standalone application. This is called Office Automation using PIA. Just add an assembly reference to Microsoft.Office.Interop.Outlook.dll (C:\Program Files (x86)\Microsoft Visual Studio 10.0\Visual Studio Tools for Office\PIA\Office12\Microsoft.Office.Interop.Outlook.dll). In code, you just need a reference to an `Outlook.Application` instance.

Outlook.Application app = new Outlook.Application();
Outlook.Explorer explorer = app.ActiveExplorer();
explorer.Display(); // display explorer
Outlook.MailItem mailItem = app.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.Display(); // create mail message

You also need to be sure you properly dispose of COM resources.

Problem

All information on the MSDN site seems to assume one is creating Outlook add-ins that use these objects. However, I am wondering if it's possible to create new or referenced `Explorer` objects that contain `MailItems`, etc. that can be used within a standalone application?

Original source