Opening a Message

    To open a message
  1. Retrieve the message's entry identifier from one of the following sources:
  2. Call one of the following OpenEntry methods to open the message, setting lpEntryID to the message's entry identifier:

    IMAPIFolder::OpenEntry

    IMsgStore::OpenEntry

    IMAPISession::OpenEntry

    The fastest method is usable only for incoming messages and involves calling the receive folder's IMAPIFolder::OpenEntry method. The next fastest method, calling the message store's IMsgStore::OpenEntry method, is usable for all messages as is the slowest method, calling IMAPISession::OpenEntry.

Note Folders and their contents tables can be closed at any time without adversely affecting any of the messages that were opened from within them.

    To open a message that has been saved on disk
  1. Call StgOpenStorage to retrieve an IStorage interface pointer, passing the name of the message file for the pwcsName parameter.
LPSTORAGE pStorage = NULL;
HRESULT hr = StgOpenStorage (L"MESSAGE.MSG", NULL,
                             STGM_TRANSACTED |
                             STGM_READWRITE |
                             STGM_SHARE_EXCLUSIVE,
                             NULL, 0, &pStorage);
  1. Call OpenIMsgOnIStg to retrieve an IMessage interface pointer to access the message.
LPMESSAGE pMessage = NULL;
LPMALLOC pMalloc = MAPIGetDefaultMalloc();
hr = OpenIMsgOnIStg (NULL, MAPIAllocateBuffer, MAPIAllocateMore,
                     MAPIFreeBuffer, pMalloc, NULL, pStorage,
                     NULL, 0, 0, &pMessage);