次の方法で共有


Opening a Message

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This page may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.

To open a message

  1. Retrieve the message's entry identifier from one of the following sources:

    • The row that represents the message in the contents table of its parent folder. For more information about working with a folder contents table, see Contents Tables.

    • The lpEntryID member of the NEWMAIL_NOTIFICATION structure that is sent with a new mail notification. For more information about receiving and handling notifications, see Handling Notifications.

    • A call to the message's IMAPIProp::GetProps method requesting the PR_ENTRYID (PidTagEntryId) property.

  2. Call one of the following OpenEntry methods to open the message, setting lpEntryID to the message's entry identifier:

    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.

NoteNote

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);
    
  2. 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);