This topic has not yet been rated - Rate this topic

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

Published: July 16, 2012

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:
© 2014 Microsoft. All rights reserved.