Home
Fractals
Tutorials
Books
My blog
My LinkedIn Profile

BOOKS i'm reading

Napoleon Hill Keys to Success: The 17 Principles of Personal Achievement, Napoleon Hill, ISBN: 978-0452272811
The 4-Hour Workweek: Escape 9-5, Live Anywhere, and Join the New Rich (Expanded and Updated), Timothy Ferriss, ISBN: 978-0307465351
The Fountainhead, Ayn Rand, ISBN: 0452273331

Automate Microsoft Outlook from C++

Olivier Langlois, IT superstar coach, Dominate LinkedIn Formula author
by Olivier Langlois

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 :: Books :: My blog :: My LinkedIn Profile :: Contact