Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All
Expand Minimize

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 HrUnWrapMDB(LPMDB lpMDBIn, LPMDB* lppMDBOut)
{
    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
            lpUnwrappedMDB->AddRef();
            (*lppMDBOut) = lpUnwrappedMDB;
        }
    }
    if (lpProxyObj) lpProxyObj->Release();
    return hRes;
}


Community Additions

ADD
Show:
© 2015 Microsoft