MORE INFORMATION
If Outlook 2003 is running in Cached Exchange Mode, any
Extended MAPI applications that log on to the same session are also connected
to the cached message store. Any data that is accessed and any changes that are
made will be made against the local copy of the mailbox. Sometimes, you do not
want this to occur. Outlook 2003 includes a new flag that is named
MDB_ONLINE:
#define MDB_ONLINE ((ULONG) 0x00000100)
This flag can be passed to the
IMAPISession::OpenMsgStore MAPI function. This flag overrides the connection to the local
message store and opens the store on the remote server.
Note This flag will not permit the Exchange store to be opened in
cached mode and in non-cached mode at the same time in the same MAPI session.
If you have already opened the cached message store, you must either close the
store before you open it with this flag or open a new MAPI session where you
can open the Exchange store on the remote server by using this
flag.
The following code demonstrates how to use this flag:
//Obtain the table of all the message stores that are available
hRes = lpMAPISession -> GetMsgStoresTable(0, &pStoresTbl);
//Set up restrictions for the default store
sres.rt = RES_PROPERTY; //Comparing a property
sres.res.resProperty.relop = RELOP_EQ; //Testing equality
sres.res.resProperty.ulPropTag = PR_DEFAULT_STORE; //Tag to compare
sres.res.resProperty.lpProp = &spv; //Prop tag and value to compare against
spv.ulPropTag = PR_DEFAULT_STORE; //Tag type
spv.Value.b = TRUE; //Tag value
//Convert the table to an array that can be stepped through
//Only one message store should have PR_DEFAULT_STORE set to true, so that only one will be returned
hRes = HrQueryAllRows(
pStoresTbl, //Table to query
(LPSPropTagArray) &sptCols, //Which columns to obtain
&sres, //Restriction to use
NULL, //No sort order
0, //Max number of rows (0 means no limit)
&pRow); //Array to return
//Open the first returned (default) message store
hRes = lpMAPISession->OpenMsgStore(
NULL, //Window handle for dialogs
pRow->aRow[0].lpProps[EID].Value.bin.cb, //size and...
(LPENTRYID)pRow->aRow[0].lpProps[EID].Value.bin.lpb, //value of entry to open
NULL, //Use default interface (IMsgStore) to open store
MAPI_BEST_ACCESS | MDB_ONLINE, //Flags
&lpTempMDB); //Pointer to put the store in
Additionally, you can bypass the cache on specific items or folders by
passing the
MAPI_NO_CACHE flag to the
IMsgStore::OpenEntry MAPI function:
#define MAPI_NO_CACHE ((ULONG) 0x00000200)
The following code demonstrates how to use this flag:
// Open the root folder of the message store
hRes = lpMDB->OpenEntry(
0, // size of entry ID
NULL, // Pointer to entry ID
NULL, // Use default interface (IMAPIFolder)
MAPI_BEST_ACCESS | MAPI_NO_CACHE, // Flags
&ulObjType, // Output parameter indicates the type of object that is returned
(LPUNKNOWN *)&lpRootFolder))) // Pointer to put the opened item in
Note If you opened the message store with the
MDB_ONLINE flag, you do not have to use the
MAPI_NO_CACHE flag.