Access a store on the remote server when Outlook is in Cached Exchange Mode

Applies to: Outlook 2013 | Outlook 2016

This topic contains a code sample in C++ that shows how to use the MAPI_NO_CACHE flag to open a folder or a message on a message store on the remote server when Microsoft Office Outlook is in Cached Exchange Mode.

Cached Exchange Mode permits Outlook to use a local copy of a user's mailbox while Outlook maintains an online connection to a remote copy of the user's mailbox on the remote Exchange server. When Outlook is running in Cached Exchange Mode, by default, any MAPI solutions 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 are made against the local copy of the mailbox.

A client or service provider can override the connection to the local message store and open a message or a folder on the remote store by setting the bit for MAPI_NO_CACHE in the ulFlags parameter when calling IMsgStore::OpenEntry.

The following code sample shows how to call IMsgStore::OpenEntry with the MAPI_NO_CACHE flag set in the ulFlags parameter to open the root folder on the remote message store.

HRESULT HrOpenRootFolder ( 
    LPMDB lpMDB, 
    LPMESSAGE* lpRootFolder) 
{ 
    ULONG ulObjType = NULL; 
    HRESULT 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 returned 
        (LPUNKNOWN *) lpRootFolder));           // Pointer to put the opened folder in 
    return hRes; 
 
}

If you opened the message store with the MDB_ONLINE flag on the remote server, you do not have to use the MAPI_NO_CACHE flag.

See also