Home
Fractals
Tutorials
SetLib
Books
Archive
My blog

BOOKS i'm reading

Distributed Systems Concepts and design fourht edition ISBN:0321263545
Advanced Programming in the UNIX(R) Environment (2nd Edition), W. Richard Stevens, Stephen A. Rago, ISBN:0201433079
Cascading Style Sheets: The Definitive Guide, Eric A. Meyer, ISBN:0596005253

Automate Microsoft Outlook from C++

C++ Microsost Outlook automation demo sample program preview

Contents

Introduction

Automating Microsoft Office applications can be alot of fun and there exist a lot of resources on Internet about how to do it from Visual Basic. However, if you program in C++, you are out of luck. It is not that it is very difficult to do but you are pretty much on your own to figure out what are the steps to do it. You will have to read Visual Basic articles and have some knowledge about how COM works to be able to connect the dots between the Visual Basic procedure and how to apply this knowledge to a C++ environment. In this C++ Windows programming tutorial, I am describing step by step how to write a C++ Windows program that is sending an e-mail through Microsoft Outlook.

How to start

First, you have to collect information about the Microsoft Outlook COM interfaces. The best tool to discover this information is the oleview tool. It is installed with Visual Studio and located in the Common/Tools directory. You can also access it from the Visual Studio's Tools menu. When inside this tool, find "Microsoft Outlook library" in the Type Libraries section:

OLE/COM Object Viewer

In the registry section of the tool, there is already interesting information worth mentionning. The msoutl.olb file is the COM Type library of Outlook that contains all the information about the COM interfaces available from Outlook. More information about Type Libraries are available from (Brockschmidt,1995) and (Box,1998).This file will be used by the C++ compiler to generate C++ header files declaring C++ classes for our program to use the Outlook COM interfaces. Another useful information is the HELPDIR field. I will have more to say about it in a second. For now, we will consult the msoutl.olb content by double clicking on the "Microsoft Outlook Object Library". The ITypeLib Viewer will pop up and show the following information:

ITypeLib Viewer

The first thing that you should notice is the statement helpfile("VBAOL11.CHM"). Before continuing, you should check if this file present in the HELPDIR directory as it is not installed by default when installing Microsoft Office. It is the VBA Outlook object library API reference manual. It will be your best friend when you are going to automate Outlook from your programs. I have found that the best way to get the file installed was to actually try to access it from Outlook. Here is a way to do it:

  • From Outlook, type Alt+F11 to invoke the VBA editor.
  • Press F2 to invoke the Object Browser and select the Outlook library to narrow your search.
  • Select a class or a member and then click on the question mark button to access the help file.

Microsoft Outlook VBA Object Browser

Now that the preliminaries are done, we are ready to start coding our C++ program. So lets go to the next section.

Page 1 2 3 4

Home :: Fractals :: Tutorials :: SetLib :: Books :: Archive :: My blog :: Contact