none
convert sbinary to entryid RRS feed

  • Question

  • From a MAPI session, I have successfully called GetMsgStoresTable and retrieved a stores table of one row.  Now, I'm trying to get the entry id for that message store and open the message store.

    One of the columns I requested in GetMsgStoresTable is PR_ENTRYID.  In that column, I see an SBinary struct.   (The value matches the value displayed by MFCMapi, so I'm encouraged that I've fetched it correctly.)

    Now, I'd like to open the store.  However, that takes an ENTRYID struct, and I have no idea how to create one of those from an SBinary.  What should I do?

    Thanks.

    Wednesday, February 8, 2012 4:13 PM

Answers

  • Figured this out.  So, I'll share it for those who still need to know :)

    All you need to do is cast the SBinary*to an ENTRYID*.  The ENTRYID struct does not have a field for its size, so you need to keep track of that externally.  It appears that any functions taking an ENTRYID param also have a size param, so the easiest is to simply keep the entryid in its SBinary form. 

    For example:

    Assume "i" represents a column containing an ENTRYID and row is a IMAPITable row from a query:

    SBinary* entryId = row->lpProps [i].Value.bin;

    Later, use the entryId like this:

    HRESULT hr = session->OpenMsgStore (
      NULL,
      entryId->cb,
      (ENTRYID*)storeId->lpb,
      NULL,
      MDB_NO_MAIL,
      &messageStore);

    • Marked as answer by perih Friday, February 10, 2012 9:16 PM
    Friday, February 10, 2012 9:14 PM