• Question

  • I am trying to retrieve the recipients of an Outlook message file.  According to the docs:

    Clients can retrieve a message's recipient table by calling 
    its IMessage::GetRecipientTable method or its 
    IMAPIProp::OpenProperty method. For more information, see 
    IMessage::GetRecipientTable and IMAPIProp::OpenProperty. 
    Message store providers are expected to support both of these 
    approaches. The OpenProperty approach requires that the 
    client specify IID_IMAPITable as the interface identifier and 
    PR_MESSAGE_RECIPIENTS as the property tag.

    I'm trying the OpenProperty approach.  But when I call OpenProperty using the code below, I get MAPI_E_INTERFACE_NOT_SUPPORTED. This is my code:

    #define USES_IID_IMAPITable #include <initguid.h> #include <Mapiutil.h> #include <IMessage.h>

    // [...inside a function...]

    // Initialize the MAPI library if (FAILED(ScInitMapiUtil(0))) { return E_UNEXPECTED; } // Open up the .msg file CComPtr<IStorage> pStorage; if (FAILED(StgOpenStorage( pszFilePath, NULL, grfMode, NULL, 0, &pStorage ))) { return E_UNEXPECTED; } // Get the IMessage object CComPtr<IMessage> pMessage; CComPtr<IMalloc> pMalloc = MAPIGetDefaultMalloc(); if (FAILED(OpenIMsgOnIStg( NULL, MAPIAllocateBuffer, MAPIAllocateMore, MAPIFreeBuffer, pMalloc, NULL, pStorage, NULL, 0, 0, &pMessage ))) { return E_UNEXPECTED; }

    // Try to open the recipients property <========== this is the point of failure LPMAPITABLE pmt; HRESULT hr = pMessage->OpenProperty( PR_MESSAGE_RECIPIENTS, &IID_IMAPITable, 0, 0, (LPUNKNOWN*)&pmt);

    Any ideas on what's wrong?

    Wednesday, November 13, 2019 1:02 AM


  • Why not call IMessage::GetRecipientTable?  If this call succeeds use it.
    • Marked as answer by amt528 Wednesday, November 13, 2019 2:30 PM
    Wednesday, November 13, 2019 1:53 PM

All replies