Microsoft KB Archive/252649: Difference between revisions
From BetaArchive Wiki
(importing KB archive) |
m (Text replacement - ">" to ">") |
||
Line 68: | Line 68: | ||
//Find CDO's StoreID | //Find CDO's StoreID | ||
bstr_t szStoreEID = pCDOMessage- | bstr_t szStoreEID = pCDOMessage->StoreID; | ||
//Convert the StoreID to a byte array for OpenMsgStore | //Convert the StoreID to a byte array for OpenMsgStore | ||
Line 75: | Line 75: | ||
FBinFromHex(szStoreEID, (LPBYTE)pbSEID); | FBinFromHex(szStoreEID, (LPBYTE)pbSEID); | ||
hRes = lpMAPISession- | hRes = lpMAPISession->OpenMsgStore( | ||
0, | 0, | ||
cbSEID, | cbSEID, | ||
Line 85: | Line 85: | ||
if (FAILED(hRes)) return hRes; | if (FAILED(hRes)) return hRes; | ||
_variant_t lClass = pMessage- | _variant_t lClass = pMessage->Class; | ||
//Find the CDO message's Entry ID | //Find the CDO message's Entry ID | ||
Line 92: | Line 92: | ||
{ | { | ||
//CDO tacks on 80 extra bytes to appointment item IDs. Skip them. | //CDO tacks on 80 extra bytes to appointment item IDs. Skip them. | ||
szEID = ((char *)(bstr_t)pMessage- | szEID = ((char *)(bstr_t)pMessage->ID)+80; | ||
} | } | ||
else | else | ||
{ | { | ||
szEID = pCDOMessage- | szEID = pCDOMessage->ID; | ||
} | } | ||
Line 104: | Line 104: | ||
FBinFromHex(szEID, (LPBYTE) pbEID); | FBinFromHex(szEID, (LPBYTE) pbEID); | ||
hRes = lpMDB- | hRes = lpMDB->OpenEntry( | ||
cbEID, | cbEID, | ||
pbEID, | pbEID, | ||
Line 114: | Line 114: | ||
if (FAILED(hRes)) return hRes; | if (FAILED(hRes)) return hRes; | ||
if (lpMDB) lpMDB- | if (lpMDB) lpMDB->Release(); | ||
return hRes; | return hRes; | ||
} | } |
Revision as of 09:44, 21 July 2020
Article ID: 252649
Article Last Modified on 8/25/2005
APPLIES TO
- Microsoft Messaging Application Programming Interface
- Microsoft Collaboration Data Objects 1.2
- Microsoft Collaboration Data Objects 1.21
This article was previously published under Q252649
SUMMARY
When you work with CDO using Microsoft Visual C++, it may sometimes be necessary to switch over to MAPI. The code in the "More Information" section shows how to take a message in CDO and open that same message in MAPI.
MORE INFORMATION
//This code assumes that CDO has been imported with the following statement //#import "cdo.dll" no_namespace //and that we have a MAPI session opened with the same profile as the CDO session. HRESULT OpenMAPIMessageFromCDOMessage( LPMAPISESSION lpMAPISession, MessagePtr pCDOMessage, LPMESSAGE* lppMessage) { HRESULT hRes = S_OK; int cbSEID; LPENTRYID pbSEID; int cbEID; LPENTRYID pbEID; //Find CDO's StoreID bstr_t szStoreEID = pCDOMessage->StoreID; //Convert the StoreID to a byte array for OpenMsgStore cbSEID = strlen(szStoreEID)/2; hRes = MAPIAllocateBuffer(cbSEID, (void **)&pbSEID); FBinFromHex(szStoreEID, (LPBYTE)pbSEID); hRes = lpMAPISession->OpenMsgStore( 0, cbSEID, pbSEID, 0, MAPI_BEST_ACCESS, &lpMDB); MAPIFreeBuffer(pbSEID); if (FAILED(hRes)) return hRes; _variant_t lClass = pMessage->Class; //Find the CDO message's Entry ID bstr_t szEID if ((LONG) lClass == 26)//that is, we have an appointment item { //CDO tacks on 80 extra bytes to appointment item IDs. Skip them. szEID = ((char *)(bstr_t)pMessage->ID)+80; } else { szEID = pCDOMessage->ID; } //Convert the ID to a byte array for OpenMsgStore cbEID = strlen(szEID)/2; hRes = MAPIAllocateBuffer(cbEID, (void **)&pbEID); FBinFromHex(szEID, (LPBYTE) pbEID); hRes = lpMDB->OpenEntry( cbEID, pbEID, 0, MAPI_BEST_ACCESS, &lpObjType, (LPUNKNOWN *) lppMessage); MAPIFreeBuffer(pbEID); if (FAILED(hRes)) return hRes; if (lpMDB) lpMDB->Release(); return hRes; }
Keywords: kbhowto kbmsg KB252649