PRB: E_FAIL Calling QueryInterface from an IUnknown Pointer Obtained from MAPIOBJECTProperty

Article translations Article translations
Article ID: 296483 - View products that this article applies to.
This article was previously published under Q296483
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all


When you query for a specific MAPI interface by using a pointer that you obtained from an Outlook object's MAPIOBJECT property, you may receive the following error message:
0x80004005 (E_FAIL)


The MAPIOBJECT property is available only for compatibility with Microsoft Collaboration Data Objects (CDO) 1.21. It is a hidden property of Outlook Object Model objects, and is not meant to be used from the Outlook object. The MAPIOBJECT property is meant to be used from the corresponding CDO object.


To use the MAPIOBJECT property, use CDO to obtain it from the corresponding CDO object.


This behavior is by design.

More information

The following code sample uses the Outlook Object Model to demonstrate the problem:
//Add code above to get an instance of the Outlook application
//and get the MAPI namespace.
RecipientPtr  recipient;
AddressEntry* pAddressEntry = NULL;
IMailUser* pMailUser = NULL;
IUnknown* pUnk = NULL;


// Get the AddressEntry of the current user.

//Get the MAPIOBJECT of the AddressEntry.

//The following line fails with 0x80004005:
hr = pUnk->QueryInterface(IID_IMailUser, (void**) &pMailUser);
The following code sample uses a CDO that allows proper access to the MAPIOBJECT property:
//Add code above to log on to a CDO session.

AddressEntryPtr pAddrEntry = NULL;
IMailUser* pMailUser = NULL;
IUnknown* pUnk = NULL;

pAddrEntry = pSession->GetCurrentUser();
pUnk = pAddrEntry->GetMAPIOBJECT();
HRESULT hr = pUnk->QueryInterface(IID_IMailUser, (void**) &pMailUser);

	SPropTagArray props;
	props.aulPropTag[0] = PR_EMAIL_ADDRESS;
	props.cValues = 1;
	SPropValue* vals = NULL;
	unsigned long valCount = 0;
	hr = pMailUser->GetProps(&props, 0, &valCount, &vals);
	MessageBox(NULL, vals->Value.lpszA, "Debug", MB_OK);


Article ID: 296483 - Last Review: October 26, 2013 - Revision: 3.0
Applies to
  • Microsoft Outlook 98 Standard Edition
  • Microsoft Outlook 2000 Standard Edition
  • Microsoft Outlook 2002 Standard Edition
kbnosurvey kbarchive kbmsg kbprb KB296483

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from