• Sign in
 
  •  
  • MSDN Blogs
  • Microsoft Blog Images
  • More ...

  • Blog Home
  • About
  • Email Blog Author
  • Share this
  • RSS for posts
  • Atom
  • RSS for comments
  • CDO (24)
  • Code Snippet (43)
  • Custom Providers (17)
  • Debugging (7)
  • DevMsgTeam (300)
  • Documentation (108)
  • DST (8)
  • EWS (7)
  • Exchange (108)
  • Gotchas (97)
  • Hotfix (28)
  • MAPI (239)
  • MAPI Download (53)
  • MFCMAPI (101)
  • MSDN (59)
  • Non Dev (11)
  • OOM (17)
  • Outlook (171)
  • Outlook 2007 Auxiliary Reference (45)
  • Outlook Integration API (12)
  • Protocol Docs (20)
  • PST/OST (23)
  • Referrals (8)
  • Vista (12)
  • WrapPST (18)
Links:
  • Download MFCMAPI
  • MFCMAPI on Facebook
  • Troubleshooting Outlook Crashes
  • Office Update Center
  • Developer Messaging Team Blog
This site is provided "AS IS" with no warranties, and confers no rights. Use of included code samples are subject to the terms specified in the Terms of Use.
Archives
  • May 2013 (2)
  • April 2013 (1)
  • March 2013 (2)
  • February 2013 (2)
  • January 2013 (2)
  • December 2012 (4)
  • November 2012 (2)
  • October 2012 (2)
  • September 2012 (1)
  • August 2012 (3)
  • June 2012 (2)
  • May 2012 (1)
  • April 2012 (3)
  • March 2012 (3)
  • February 2012 (3)
  • January 2012 (1)
  • December 2011 (3)
  • November 2011 (1)
  • October 2011 (3)
  • September 2011 (1)
  • August 2011 (1)
  • July 2011 (4)
  • June 2011 (3)
  • May 2011 (3)
  • April 2011 (3)
  • March 2011 (5)
  • February 2011 (1)
  • January 2011 (2)
  • December 2010 (1)
  • November 2010 (4)
  • October 2010 (1)
  • September 2010 (3)
  • August 2010 (5)
  • July 2010 (3)
  • June 2010 (3)
  • May 2010 (1)
  • April 2010 (3)
  • March 2010 (3)
  • February 2010 (3)
  • January 2010 (2)
  • December 2009 (3)
  • November 2009 (5)
  • October 2009 (4)
  • September 2009 (5)
  • August 2009 (5)
  • July 2009 (11)
  • June 2009 (6)
  • May 2009 (5)
  • April 2009 (3)
  • March 2009 (18)
  • February 2009 (10)
  • January 2009 (3)
  • December 2008 (2)
  • November 2008 (2)
  • October 2008 (5)
  • September 2008 (4)
  • August 2008 (10)
  • July 2008 (6)
  • June 2008 (8)
  • May 2008 (2)
  • April 2008 (4)
  • March 2008 (2)
  • February 2008 (2)
  • January 2008 (5)
  • December 2007 (3)
  • November 2007 (2)
  • October 2007 (3)
  • September 2007 (1)
  • August 2007 (4)
  • July 2007 (5)
  • June 2007 (3)
  • May 2007 (4)
  • April 2007 (1)
  • March 2007 (6)
  • February 2007 (3)
  • January 2007 (2)
  • December 2006 (4)
  • November 2006 (3)
  • October 2006 (1)
  • August 2006 (1)
  • June 2006 (5)
  • May 2006 (5)
  • December 2005 (1)
  • November 2005 (4)
  • October 2005 (2)
  • September 2005 (1)
  • April 2005 (3)
  • December 2004 (2)
  • September 2004 (2)
  • August 2004 (3)
  • July 2004 (3)

New Outlook Documentation Part 4 - IMAP Headers

MSDN Blogs > SGriffin's MAPI Internals > New Outlook Documentation Part 4 - IMAP Headers

New Outlook Documentation Part 4 - IMAP Headers

Stephen Griffin - MSFT
23 Nov 2005 10:44 AM
  • Comments 6

[This is now documented here: http://msdn.microsoft.com/en-us/library/bb820953.aspx]

[This information also published as http://support.microsoft.com/kb/912238]

Just like Cached mode has a way of accessing items in the OST without triggering a download, our IMAP provider has a mechanism for accessing items in the PST without triggering the download. In an ideal world, they'd both use the same mechanism, but nobody's perfect.

Topic
A mechanism to manage messages in an IMAP store.

IID_IProxyStoreObject
In an IMAP profile, messages in the PST can be in one of two states

  • A message in its entirety with the header and body
  • A message with only its header downloaded.

Query for this interface to access a function, UnwrapNoRef, which unwraps the IMAP store and allows access to the underlying PST. Without unwrapping, access of a message in the IMAP store can force a synchronization that will attempt to download the entire message. Using the unwrapped store allows access to the message in its current state without triggering this download.

The IMsgStore interface returned by UnwrapNoRef is identical in use to the IMsgStore that was unwrapped. The only difference is that the unwrapped store will return messages as they exist in the PST, without forcing synchronization.

If QueryInterface returns the error MAPI_E_INTERFACE_NOT_SUPPORTED, then the store was not wrapped.

Definition

#define DEFINE_PRXGUID(_name, _l) \
DEFINE_GUID(_name, (0x29F3AB10 + _l), 0x554D, 0x11D0, 0xA9, \
   0x7C, 0x00, 0xA0, 0xC9, 0x11, 0xF5, 0x0A)

DEFINE_PRXGUID(IID_IProxyStoreObject, 0x00000000L);

#define MAPI_IPROXYSTOREOBJECT_METHODS(IPURE) \
MAPIMETHOD(PlaceHolder1) () IPURE; \
MAPIMETHOD(UnwrapNoRef) (LPVOID *ppvObject) IPURE; \
MAPIMETHOD(PlaceHolder2) () IPURE;

DECLARE_MAPI_INTERFACE_(IProxyStoreObject, IUnknown)
{
   BEGIN_INTERFACE
   MAPI_IUNKNOWN_METHODS(PURE)
   MAPI_IPROXYSTOREOBJECT_METHODS(PURE)
};

Usage
Call QueryInterface on the source message store to obtain the IProxyStoreObject interface. Then call UnwrapNoRef to obtain the unwrapped store. Note that UnwrapNoRef does not addref the returned pointer.

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 we do it here:
         lpUnwrappedMDB->AddRef();
         (*lppMDBOut) = lpUnwrappedMDB;
      }
   }
   if (lpProxyObj) lpProxyObj->Release();
   return hRes;
}
[Update: Added KB link]
  • 6 Comments
Outlook, MAPI, Code Snippet, Documentation, Outlook 2007 Auxiliary Reference, DevMsgTeam, MSDN
Comments
  • Amit Joshi
    25 Nov 2005 11:14 PM
    Very interesting... :) This is one of the interfaces that we have struggled with in the past. I may be wrong but I have seen msmapi create a wraper on top of pst's wrapper. If that happens we need to remove that wrapper before the code above can get access to the underlying MDB store object. If the above scenario is right, an easier way to achieve this is using an (undocumented) API exported by MsMapi32, DDLUnwrapObjectEx as follows:


    VOID WINAPI
    DDLUnwrapObjectEx(
    IUnknown* pUnk_p,
    LVPOID* ppUnwrapped_p,
    DWORD dwFlags_p
    );

    Where
    pUnk_p - Wrapped Store pointer
    ppUnwrapped_p - Unwrapped pointer to be returned
    dwFlags - bit 1: Unwrap msmapi wrapper, bit 2: Unwrap pst wrapper, bit 3: Unknown

    Simply calling this function with flags as 0x3 will unwrap the required object upto the level of an innermost store object.

    Also this function returns an AddRef'ed out pointer and doesn't have the same quirk as the interface method UnwrapNoRef

    Makes sense?
  • Stephen Griffin - MSFT
    26 Nov 2005 3:44 PM
    Amit,
    It would be better to use the documented and supported interface than rely on reversed engineered functions whose behavior you cannot rely on.

    Steve
  • Simon Audet
    4 Jan 2006 3:15 PM
    Is there a way to get notified when Outlook finished downloading a message.

    I tought I would get notified by the AdviseSinkOnObjectModified function but this doesn't seem to work.
  • Stephen Griffin - MSFT
    6 Jan 2006 10:37 AM
    I assume you're looking at the wrapped store while Outlook is downloading the message. You might see a change in the table containing the message (haven't tested). I've always found table notifications more reliable than other kinds of notifications.
  • Simon Audet
    11 Feb 2006 3:49 PM
    Thanks Mr Griffin,

    I've implemented table notifications and they're much better than store notifications.

    Now it works!
  • Lev
    16 Mar 2010 12:50 AM

    Steve, it appears that Hotmail account(http) unwraps following steps above.  How do I actually differentiate between the two - httpStore and IMAPStore?

    Thanks!

Page 1 of 1 (6 items)
Leave a Comment
  • Please add 1 and 4 and type the answer here:
  • Post
  • © 2013 Microsoft Corporation.
  • Terms of Use
  • Trademarks
  • Privacy & Cookies
  • Report Abuse
  • 5.6.426.415