First things first.. use your workspace browser to look over the functions provided in each of the Outlook objects. Familiarise yourself with the interfaces. I will explain how a basic Automation session works.
First off, you create a _DApplication object and get a running instance of it. Attach it to the A running version of the actual application you want. Then create or obtain other objects (folders items etc) using the _DApplication interface.
A note about LPDISPATCH, an LPDISPATCH is a generic pointer to an OLE object. You call functions which return LPDISPATCH types and then you create the objects you want, and attach them to the LPDISPATCH you received like so: your_object.AttachDispatch(yourLPDISPATCH); DetachDispatch() reverses this. By default you only need to call DetachDispatch when you want to reassign an object to a new LPDISPATCH. (for example if you are iterating through an Items object and dealing with one _DNoteItem @ a time you could do this:
Items my_items;
//...initialise my_items. --we will get to this later.
LPDISPATCH lp = NULL;
_DNoteItem it;
for(int i=1;i<=my_items.GetCount();i++)
{
//set lp = next element of my_items. --we will get to this.
if(lp!=NULL)
{
it.AttachDispatch(lp);
AfxMessageBox(it.GetBody()); //display each note.
it.DetachDispatch(); //so that we will be able to Attach the next note when lp is new.
}
}
Now, Automating Outlook in C++ here we go, lots of code ahead, dont worry I try to take it all one step @ a time: Coding Examples!