Problem using MAPIOBJECT from calendar item

M

Mike M.

I have a program that uses the Outlook Object Model to gather info from a
calendar. Since upgrading to Outlook 2003 I am trying to avoid the Outlook
Object Security warning dialog when I get the calendar item body. I am
trying to use the GetMAPIOBJECT() method of the AppointmentItemPtr to see if
using that interface will allow me to get the body text without the warning.
I have tried two methods for the mapiobject; coerce the returned point into
an IMessage pointer and do a QueryInterface() on the returned IUnknown
pointer. Neither succeeds.

If I coerce the pointer I get an exception when I try to use any method of
it. For example: lpIMsg->get_To(&buf);
If I use hr = ptr_Mapi->QueryInterface(CDO::IID_IMessage, (void **)&lpIMsg)
it fails with an interface not supported error (0x8004002).

Code snippets below.

Any suggestions?

TIA


#include <cdosys_i.c>
#include <CDOSys.h>

using namespace CDO;

Outlook::MAPIFolderPtr& aFolder

Outlook::_AppointmentItemPtr aItem;
IUnknownPtr ptr_Mapi;
CDO::IMessage *lpIMsg;
HRESULT hr;

int count=aFolder->GetItems()->GetCount();

aItem = aFolder->GetItems()->Item(index);

Group=_strdup(aItem->Subject);

// Try to get the mapi object
ptr_Mapi = aItem->GetMAPIOBJECT();

lpIMsg = (CDO::IMessage*)(IUnknown*)ptr_Mapi;
// hr = ptr_Mapi->QueryInterface(CDO::IID_IMessage, (void **)&lpIMsg);

// Description = _strdup(aItem->Body);
// Use the mapiobject instead of Object Model
BSTR buf;

if(lpIMsg)
{
lpIMsg->get_To(&buf);

// release the message
// lpIMsg->Release();
// lpIMsg = NULL;
}
 
X

Xavier Roche

Mike said:
I have a program that uses the Outlook Object Model to gather info from a

Your question is a bit off-topic there, you should post in a programming
group.
trying to use the GetMAPIOBJECT() method of the AppointmentItemPtr to see if
If I use hr = ptr_Mapi->QueryInterface(CDO::IID_IMessage, (void **)&lpIMsg)
it fails with an interface not supported error (0x8004002).

I have exactly the same behaviour ; see my post in
microsoft.public.outlook.program_addins for more details ("Broken
GetMAPIOBJECT() object when calling from the outside (E_NOINTERFACE) ?").
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top