Quantcast
Channel: MFCMAPI
Viewing all articles
Browse latest Browse all 1090

Commented Unassigned: 0x80004002 in OpenProperty [17368]

$
0
0
Hi,

I am using the below code to get all the folders under the IPM_SUBTREE. Same is working fine in all computers.

However, in one of the customer machine this is not working. While analyzing the logs we have found that OpenProperty returns 0x80004002

const GUID local_IID_IMAPITable = {0x00020301,0,0, {0xC0,0,0,0,0,0,0,0x46}};
hr = lpRootFolder->OpenProperty( PR_CONTAINER_HIERARCHY,
&local_IID_IMAPITable,
0,
0,
(IUnknown**)&lpHierarchyTable);

```
BOOL CMapiSession::DisplayIPMSubTree()
{
BOOL bReturn = FALSE;

HRESULT hr = S_OK;

LPSPropValue lpProp = NULL;

LPMAPIFOLDER lpRootFolder = NULL;

LPMAPITABLE lpHierarchyTable = NULL;

LPSRowSet sRows = NULL;

LPMAPIFOLDER lpContactsFolder = NULL;

do
{
//Before the function make sure that OpenMsgStore() is done

if (NULL == m_lpMsgStore)
{
PAS_ERROR(("%s: lpMsgStore can not be empty", __FUNCTION__));

break;
}

hr = HrGetOneProp(m_lpMsgStore, PR_IPM_SUBTREE_ENTRYID, &lpProp);

if (FAILED(hr))
{
PAS_ERROR(("%s: Failed in HrGetOneProp . HRESULT=[0x%x]", __FUNCTION__, hr));

LogMapiError(hr);

break;
}

if (NULL == lpProp)
{
PAS_ERROR(("%s: PR_IPM_SUBTREE_ENTRYID is NULL.", __FUNCTION__));

break;
}

/* if (lpProp->ulPropTag != PR_ENTRYID)
{
PAS_ERROR(("%s: Returned value is not PR_ENTRYID.", __FUNCTION__));

break;
}
*/

ULONG ipmroottype;
hr = m_lpMsgStore->OpenEntry(lpProp->Value.bin.cb,
(LPENTRYID)lpProp->Value.bin.lpb,
NULL,
0,
&ipmroottype,
(IUnknown**)&lpRootFolder);

if (FAILED(hr))
{
PAS_ERROR(("%s: Failed in OpenEntry . HRESULT=[0x%x]", __FUNCTION__, hr));

LogMapiError(hr);

break;
}

if (NULL == lpRootFolder)
{
PAS_ERROR(("%s: Root is NULL", __FUNCTION__));

break;
}

if (ipmroottype!=MAPI_FOLDER)
{
PAS_ERROR(("%s: Root is not a folder", __FUNCTION__));

break;
}


const GUID local_IID_IMAPITable = {0x00020301,0,0, {0xC0,0,0,0,0,0,0,0x46}};
hr = lpRootFolder->OpenProperty( PR_CONTAINER_HIERARCHY,
&local_IID_IMAPITable,
0,
0,
(IUnknown**)&lpHierarchyTable);

if (FAILED(hr))
{
PAS_ERROR(("%s: Failed in OpenProperty . HRESULT=[0x%x]", __FUNCTION__, hr));

LogMapiError(hr);

break;
}

if (lpHierarchyTable == NULL)
{
PAS_ERROR(("%s: lpHierarchyTable is NULL ", __FUNCTION__));

break;
}

SizedSPropTagArray(3, cols) = {3, {PR_ENTRYID, PR_DISPLAY_NAME, PR_CONTAINER_CLASS} };

hr = HrQueryAllRows( lpHierarchyTable,
(SPropTagArray*)&cols,
NULL,
NULL,
0,
&sRows);

if (FAILED(hr))
{
PAS_ERROR(("%s: Failed in HrQueryAllRows . HRESULT=[0x%x]", __FUNCTION__, hr));

LogMapiError(hr);

break;
}

if (sRows == NULL)
{
PAS_ERROR(("%s: sRows is NULL ", __FUNCTION__));

break;
}

for (unsigned int i=0; i<sRows->cRows; i++)
{
std::wstring csFolderName = sRows->aRow[i].lpProps[1].Value.lpszW;

std::wstring csContainerClass;

if(PROP_TYPE(sRows->aRow[i].lpProps[2].ulPropTag) != PT_NULL)
{
if(PROP_TYPE(sRows->aRow[i].lpProps[2].ulPropTag) != PT_ERROR)
{
if (sRows->aRow[i].lpProps[2].Value.err != MAPI_E_NOT_FOUND)
{
csContainerClass = sRows->aRow[i].lpProps[2].Value.lpszW;
}
}
}

PAS_TRACE(("%s: Folder=[%s], ContainerClass=[%s] ", __FUNCTION__, csFolderName.c_str(), csContainerClass.c_str()));
}

bReturn = TRUE;
}
while(FALSE);

if (lpContactsFolder)
{
PAS_TRACE(("%s: Freeing the lpContactsFolder-2", __FUNCTION__));

lpContactsFolder->Release();

lpContactsFolder = NULL;
}

if (sRows)
{
PAS_TRACE(("%s: Freeing the sRows", __FUNCTION__));

FreeProws(sRows);

sRows = NULL;
}

if (lpHierarchyTable)
{
PAS_TRACE(("%s: Freeing the lpHierarchyTable", __FUNCTION__));

lpHierarchyTable->Release();

lpHierarchyTable = NULL;
}

if (lpRootFolder)
{
PAS_TRACE(("%s: Freeing the lpRootFolder", __FUNCTION__));

lpRootFolder->Release();

lpRootFolder = NULL;
}

if (lpProp)
{
PAS_TRACE(("%s: Freeing the lpProp", __FUNCTION__));

MAPIFreeBuffer(lpProp);

lpProp = NULL;
}

return bReturn;
}


```
Do let me know if you need any more details. Any help is appreciated.

Regards,
Rohan
Comments: ** Comment from web user: shetty_rohan **

I had a misunderstanding while posting this issue. I thought I could also post "MAPI problems" here.

Anyways, sorry for that.


Viewing all articles
Browse latest Browse all 1090

Latest Images

Trending Articles



Latest Images