BOOKS i'm reading
Automate Microsoft Outlook from C++
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.
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:
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:
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:
Now that the preliminaries are done, we are ready to start coding our C++ program. So lets go to the next section.