This documentation is archived and is not being maintained.

How to: Access a Message on an IMAP Store Without Downloading the Entire Message

Office 2007

This topic shows a code sample in C++ that queries a message store for the IProxyStoreObject interface, and uses the returned pointer and the IProxyStoreObject::UnwrapNoRef function to obtain a pointer to an IMAP store object that has been unwrapped. Using this unwrapped store allows access to a message in its current state without invoking a download of the entire message.

Because UnwrapNoRef does not increment the reference count for this new pointer to the unwrapped store object, after successfully calling UnwrapNoRef, you must call IUnknown::AddRef to maintain the reference count.

    HRESULT hRes = S_OK;
    IProxyStoreObject* lpProxyObj = NULL;
    LPMDB lpUnwrappedMDB = NULL;
    hRes = lpMDBIn->QueryInterface(IID_IProxyStoreObject,(void**)&lpProxyObj);
    if (SUCCEEDED(hRes) && lpProxyObj)
        hRes = lpProxyObj->UnwrapNoRef((LPVOID*)&lpUnwrappedMDB);
        if (SUCCEEDED(hRes) && lpUnwrappedMDB)
            // UnwrapNoRef doesn't addref, so do it here
            (*lppMDBOut) = lpUnwrappedMDB;
    if (lpProxyObj) lpProxyObj->Release();
    return hRes;