Microsoft KB Archive/296483

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

Article ID: 296483

Article Last Modified on 3/4/2004

-

APPLIES TO


 * Microsoft Outlook 98 Standard Edition
 * Microsoft Outlook 2000 Standard Edition
 * Microsoft Outlook 2002 Standard Edition

-



This article was previously published under Q296483



SYMPTOMS
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)



CAUSE
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.



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



STATUS
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; HRESULT hr;

pNameSpace->get_CurrentUser(&recipient);

// Get the AddressEntry of the current user. recipient->get_AddressEntry(&pAddressEntry);

//Get the MAPIOBJECT of the AddressEntry. pAddressEntry->get_MAPIOBJECT(&pUnk);

//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);

if(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, &quot;Debug&quot;, MB_OK); }

Keywords: kbmsg kbprb KB296483

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.