Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles / Languages / C++/CLI

Outlook Interop, Including Distribution Lists

3.00/5 (1 vote)
2 Mar 2009CPOL 19.6K   209  
Re-usable code to manage Outlook.

Introduction

Apparently, the DLLs for interop with Outlook have changed through the years. After unsuccessfully trying literally hundreds of articles while searching for online-submitted source code for Outlook interop (even the documentation on MSDN was quite confusing), I decided to create my own code.

The submitted, zipped, working code provided is very terse, fairly easy to understand, and is even easier to employ. The code worked well on an older IBM laptop with the XP-Pro Operating System and Office 2003.

Using the code

To re-use the code, use the ofOutlook.h and ofOutlook.cpp files in your Visual Studio project. Then, simply use an include directive, such as demonstrated in the (Form1.h) file, then add the methods that you would like to have in your form... or even in command-line/non-GUI programs.

The files are very small, once unzipped. A snippet from one of the files follows:

C++
// A snippet from ofOutlook.h containing the initial declarations that 
// will identify the locations necessary for the Microsoft DLL to work.
//
private:
   static Outlook::ApplicationClass^ myOutlook = gcnew Outlook::ApplicationClass();
   static Outlook::NameSpace^ myNs = myOutlook->GetNamespace("MAPI");
   static Outlook::MAPIFolder^ folderContacts = 
          myNs->GetDefaultFolder(Outlook::OlDefaultFolders::olFolderContacts);

Points of interest

This code was functional as of early December's upgrades to XP and Office 2003. But your mileage may vary - YMMV (for Europeans, your consumption may vary).

History

This is the original article.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)