I am getting E_NOINTERFACE while using QueryInterfaceof for IID_I



I am using following code for querying interfaces.

HResult hr = MAPILogonEx ( NULL, (LPTSTR)lpcszProfile, (LPTSTR) Password,
MAPI_EXTENDED|MAPI_UNICODE|MAPI_NEW_SESSION|MAPI_NO_MAIL|MAPI_TIMEOUT_SHORT, &m_pSession );
CByteArray baEntryID;
LPMAPITABLE pMsgStoresTable;
hr = pSession->GetMsgStoresTable ( 0, &pMsgStoresTable );
bool bFoundEntryID = false;
if (SUCCEEDED ( hr ) )
{
static const SizedSPropTagArray ( 3L, spta ) =
{ 3L, { PR_DISPLAY_NAME_A, PR_ENTRYID, PR_MDB_PROVIDER } };
LPSRowSet lprs;
hr = HrQueryAllRows ( pMsgStoresTable, (LPSPropTagArray) &spta, NULL, NULL,
0, &lprs );
if ( SUCCEEDED ( hr ) )
{
//Hunt for the one of interest (or present dialog for user to choose)
for ( ULONG nIdx = 0; nIdx < lprs->cRows && ! bFoundEntryID; nIdx++ )
{
SRow& ThisRow = lprs->aRow[nIdx];

SPropValue& DisplayNameProp = ThisRow.lpProps[0];
SPropValue& EntryIDProp = ThisRow.lpProps[1];
SPropValue& ProviderIDProp = ThisRow.lpProps[2];

LPSTR lpszDisplayName = DisplayNameProp.Value.lpszA;
SBinary binEntryID = EntryIDProp.Value.bin;
SBinary binProviderID = ProviderIDProp.Value.bin;
//check the provider ID to see if it is MS-Exchange based
if ( sizeof(GUID) == binProviderID.cb ) //
{
if ( 0 == memcmp ( binProviderID.lpb, pbExchangeProviderPrimaryUserGuid,
sizeof(GUID) ) ||
0 == memcmp ( binProviderID.lpb, pbExchangeProviderDelegateGuid,
sizeof(GUID) ) ||
0 == memcmp ( binProviderID.lpb, pbExchangeProviderPublicGuid,
sizeof(GUID) ) ||
0 == memcmp ( binProviderID.lpb, pbExchangeProviderXportGuid,
sizeof(GUID) ) )
{
baEntryID.SetSize ( binEntryID.cb );
CopyMemory ( baEntryID.GetData(), binEntryID.lpb, binEntryID.cb );
bFoundEntryID = true;
}
}
}
}
}
if (bFoundEntryID)
{
LPMDB pMsgStore = NULL;
hr = m_pSession->OpenMsgStore ( NULL, baEntryID.GetSize(), (LPENTRYID)
baEntryID.GetData(),
&IID_IMsgStore, MDB_NO_DIALOG|MDB_NO_MAIL, &pMsgStore );
if ( (SUCCEEDED ( m_hr )) || ( m_hr == MAPI_W_ERRORS_RETURNED && pMsgStore)
)
{
hr = pMsgStore->QueryInterface(IID_IExchangeManageStore4, (void **)
&m_pExMgStore);
// here I get E_NOINTERFACE
}
}

I am using outlook 2007 profile and ESMMDB32.dll of version 12.0.6211.1000.
Please help me to resolve this problem of IID_IExchangeManageStore4.

Thanks in advanced

.



Relevant Pages


Loading