C
Chuck Bohling
I'm trying to capture outlook events using the object model and C++. I
successfully set an IConnectionPoint::Advise sink for outlook's
ApplicationEvents. I get Startup, NewMail, etc. events just as expected.
However, when I try to set an Advise sink for a MAPIFolder's FolderEvents,
nothing happens. No events are sent. I've checked to make sure I have the
correct folder. Everything seems ok. There are no errors in the code that
sets the sink. In fact, my sink's QueryInterface is called, with
IID_IDispatch. It looks like it should work but doesn't. Anyone have any
thoughts. Here the code. Thanks.
_ApplicationPtr app = g_dispatch; // from outlook
_NameSpacePtr ns = app->GetNamespace("MAPI");
MAPIFolderPtr folder = ns->GetDefaultFolder(olFolderInbox);
MAPIFolderPtr subFolder = folder->Folders->Item(1);
_FoldersPtr folders = subFolder->Folders;
IConnectionPointContainerPtr connectionPointContainer = folders;
if (connectionPointContainer != NULL)
{
IConnectionPoint *connPoint = NULL;
connectionPointContainer->FindConnectionPoint(__uuidof(FoldersEvents),
&connPoint);
IConnectionPointPtr connectionPoint = connPoint;
if (connectionPoint != NULL)
{
ULONG cookie;
SQFoldersEventsPtr events = new SQFoldersEvents;
connectionPoint->Advise(events, &cookie);
}
}
successfully set an IConnectionPoint::Advise sink for outlook's
ApplicationEvents. I get Startup, NewMail, etc. events just as expected.
However, when I try to set an Advise sink for a MAPIFolder's FolderEvents,
nothing happens. No events are sent. I've checked to make sure I have the
correct folder. Everything seems ok. There are no errors in the code that
sets the sink. In fact, my sink's QueryInterface is called, with
IID_IDispatch. It looks like it should work but doesn't. Anyone have any
thoughts. Here the code. Thanks.
_ApplicationPtr app = g_dispatch; // from outlook
_NameSpacePtr ns = app->GetNamespace("MAPI");
MAPIFolderPtr folder = ns->GetDefaultFolder(olFolderInbox);
MAPIFolderPtr subFolder = folder->Folders->Item(1);
_FoldersPtr folders = subFolder->Folders;
IConnectionPointContainerPtr connectionPointContainer = folders;
if (connectionPointContainer != NULL)
{
IConnectionPoint *connPoint = NULL;
connectionPointContainer->FindConnectionPoint(__uuidof(FoldersEvents),
&connPoint);
IConnectionPointPtr connectionPoint = connPoint;
if (connectionPoint != NULL)
{
ULONG cookie;
SQFoldersEventsPtr events = new SQFoldersEvents;
connectionPoint->Advise(events, &cookie);
}
}