S
Stefan Richter via OfficeKB.com
I tried to get access to the MAPIOBJECT of a MailItem. But everytime I call
QueryInterface() from the MAPIOBJECT I got the following exception:
Unhandled Exception in OUTLOOK.EXE (EXSEC32.DLL): 0xC0000005: Access
Violation
Stefan
Short snippet of code:
#include "stdafx.h"
#define INITGUID
#include <objbase.h>
#define USES_IID_IMessage
#include <mapix.h>
#include <mapitags.h>
#include <mapidefs.h>
#include <mapiutil.h>
#include <mapiguid.h>
#include "OutlookAddin.h"
#include "Addin.h"
....
void __stdcall CAddin::OnItemSend(IDispatch* Ctrl,VARIANT_BOOL *
CancelDefault)
{
HRESULT hr;
Outlook::_MailItemPtr MailItem;
IMessage *pMsg = NULL;
IUnknown *pUnk = NULL;
Ctrl->QueryInterface(Outlook::IID__MailItem, (void**)&MailItem);
MailItem->get_MAPIOBJECT(&pUnk);
hr = pUnk->QueryInterface((IID_IMessage), (void**)pMsg); // This call ends
everytime in an exception.
....
QueryInterface() from the MAPIOBJECT I got the following exception:
Unhandled Exception in OUTLOOK.EXE (EXSEC32.DLL): 0xC0000005: Access
Violation
Stefan
Short snippet of code:
#include "stdafx.h"
#define INITGUID
#include <objbase.h>
#define USES_IID_IMessage
#include <mapix.h>
#include <mapitags.h>
#include <mapidefs.h>
#include <mapiutil.h>
#include <mapiguid.h>
#include "OutlookAddin.h"
#include "Addin.h"
....
void __stdcall CAddin::OnItemSend(IDispatch* Ctrl,VARIANT_BOOL *
CancelDefault)
{
HRESULT hr;
Outlook::_MailItemPtr MailItem;
IMessage *pMsg = NULL;
IUnknown *pUnk = NULL;
Ctrl->QueryInterface(Outlook::IID__MailItem, (void**)&MailItem);
MailItem->get_MAPIOBJECT(&pUnk);
hr = pUnk->QueryInterface((IID_IMessage), (void**)pMsg); // This call ends
everytime in an exception.
....