How to use the Cached Exchange Mode feature with extended MAPI applications in Outlook 2003

Support for Office 2003 has ended

Microsoft ended support for Office 2003 on April 8, 2014. This change has affected your software updates and security options. Learn what this means for you and how to stay protected.

This article has been archived. It is offered "as is" and will no longer be updated.
Cached Exchange Mode is a new feature in Microsoft Office Outlook 2003. Cached Exchange Mode permits Outlook 2003 to use a local copy of a user's mailbox while Outlook 2003 maintains an online connection to a remote copy of the user's mailbox in Microsoft Exchange. It is important for Extended MAPI developers to understand how this feature affects their solutions and how they can work with this feature.
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.

Article ID: 834496 - Last Review: 01/12/2015 23:06:51 - Revision: 3.0

  • Microsoft Office Outlook 2003
  • kbnosurvey kbarchive kbprogramming kbsample kbmsg kbinfo KB834496