February 24, 2021
Hot Topics:

Interacting with Outlook from a WinForms Application

  • By Rachel Wireman
  • Send Email »
  • More Articles »


Interacting with Microsoft Office (as well as taking advantage of the mountains of built-in classes and functions) can be a powerful addition to your business applications. You can perform highly valued operations using the interoperability assemblies that ship with Office products to give the user an experience that will be familiar and easy to adopt. This article is the first part of a two-part series. It will focus on interacting with Outlook within the context of a .NET application. You will create a simple example to familiarize yourself with the Outlook interoperability classes, specifically dealing with the manipulation of Outlook contact items. It will also discuss briefly the security implications associated with Outlook interaction from your .NET application. Part Two of this series will cover extending Outlook via an add-in, illustrating how to add a custom button to the Outlook toolbar.


The Redemption DLL is one way to avoid the security warnings introduced by the "Outlook Security Patch" included in Office 2002 and later when accessing information deemed to be sensitive. For example, when you try to access a contact's email property later in this article, without Redemption when your application makes the call to Outlook for the information, Outlook displays the following message to the user:

If you do not mind inconveniencing your users with such warnings and plan to train them on the appropriate response to said dialogs, you can skip the rest of this section and all later references to Redemption. Less sadistic coders will be interested in the fact that the Redemption library exposes a method to access "sensitive" information without warnings. Redemption is available free for development purposes but requires a onetime licensing fee when distributing it with your applications. For more information about this library and to download the DLL, navigate here.

The source code sample included with this article does not use Redemption in case you choose not to download it; however, the code includes lines where Redemption could be used but are commented out. Also, note that no error catching is present in this sample code for the case when your user chooses to deny a security access request. You will want to add error checking in a real-world application. Redemption would avoid these scenarios.

If you decide to use Redemption, you will have to register the DLL on your computer by issuing the following command at a command prompt after navigating to the folder location of the DLL:

RegSvr32 Redemption.dll

You will also need to add a reference to the DLL in your solution before re-instating the code that uses Redemption to suppress the warnings.

Getting Started

Unlike Redemption, the Outlook COM library is a necessary reference for building an application that interacts with Outlook. For this article and its sample, I am using Visual Studio 2005 (.NET Framework 2.0), C#.NET, and Microsoft Office Outlook 2003. The first step is to add a reference to the appropriate Outlook COM library in your project. The Office interop libraries are located under the COM tab of the references dialog in Visual Studio. In my case, because I am using Outlook 2003, the library is called "Microsoft Outlook 11.0 Object Library." These interop libraries ship with Office. Therefore, if you have Outlook 2003 installed on your machine, this is the library you will see. If you have Outlook 2007 installed, instead you will see "Microsoft Outlook 12.0 Object Library."

In each class that will use the Outlook functionality, you will also want to include the following using directive:

using Outlook = Microsoft.Office.Interop.Outlook;

Please note that you may need to adjust the references in the sample project to run it with your machine's configuration.

Page 1 of 4

This article was originally published on September 24, 2007

Enterprise Development Update

Don't miss an article. Subscribe to our newsletter below.

Thanks for your registration, follow us on our social networks to keep up-to-date