Y
yg
HI, I am building a COM Addin for Outlook 2000+ using VC++ 6.0
In my Event Handler - OnItemSend, I am trying to get the Mapi object
pointer so that I can get some properties from it like TextBody or any
other
available property. But the proble is that whenever I am calling a
method, I get a memoty violation failure. Below is my code. Can anyone
help me figure out what I am doing wrong. Thanks alot.
void __stdcall CAddin::OnItemSend(IDispatchPtr pDisp,VARIANT_BOOL
*pCancel)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HRESULT hr = S_OK;
CComQIPtr<Outlook::_MailItem> spMail(pDisp);
CComQIPtr<Outlook::Recipients> spRecipients;
CComQIPtr<Outlook::Recipient> spRecipient;
CComQIPtr<Outlook::Attachments> spAttachments;
CComQIPtr<Outlook::Attachment> spAttachment;
IMessage* pMsg = NULL;
IBodyPart* pBp = NULL;
IConfiguration* pConfig = NULL;
Fields* pFlds = NULL;
Field* pFld = NULL;
_Stream* pStm = NULL;
IUnknown* pUnk = NULL;
spMail->get_MAPIOBJECT(&pUnk);
hr = pUnk->QueryInterface(__uuidof(IMessage), (void**) pMsg);
..
..
..
..
..
..
}
But the pMsg pointer is allways NULL and I get a negative hr value
back.
if I try it like this:
spMail->get_MAPIOBJECT(&pUnk);
pMsg = (IMessage*) pUnk;
pMsg->get_BodyText(&bsBodyText)
then I get a memory viloattion error.
So how do I get a Mapi object pointer inside the OnItemSend event
handler ?
thanks !
In my Event Handler - OnItemSend, I am trying to get the Mapi object
pointer so that I can get some properties from it like TextBody or any
other
available property. But the proble is that whenever I am calling a
method, I get a memoty violation failure. Below is my code. Can anyone
help me figure out what I am doing wrong. Thanks alot.
void __stdcall CAddin::OnItemSend(IDispatchPtr pDisp,VARIANT_BOOL
*pCancel)
{
AFX_MANAGE_STATE(AfxGetStaticModuleState());
HRESULT hr = S_OK;
CComQIPtr<Outlook::_MailItem> spMail(pDisp);
CComQIPtr<Outlook::Recipients> spRecipients;
CComQIPtr<Outlook::Recipient> spRecipient;
CComQIPtr<Outlook::Attachments> spAttachments;
CComQIPtr<Outlook::Attachment> spAttachment;
IMessage* pMsg = NULL;
IBodyPart* pBp = NULL;
IConfiguration* pConfig = NULL;
Fields* pFlds = NULL;
Field* pFld = NULL;
_Stream* pStm = NULL;
IUnknown* pUnk = NULL;
spMail->get_MAPIOBJECT(&pUnk);
hr = pUnk->QueryInterface(__uuidof(IMessage), (void**) pMsg);
..
..
..
..
..
..
}
But the pMsg pointer is allways NULL and I get a negative hr value
back.
if I try it like this:
spMail->get_MAPIOBJECT(&pUnk);
pMsg = (IMessage*) pUnk;
pMsg->get_BodyText(&bsBodyText)
then I get a memory viloattion error.
So how do I get a Mapi object pointer inside the OnItemSend event
handler ?
thanks !