Platform SDK: MAPI

Receiving Messages with TNEF Custom Attachment Processing

To receive a TNEF message with customized attachment processing

  1. Import all the transmittable properties — those that the messaging system supports — from the incoming message into a new MAPI message. This includes the message text, which contains the TNEF data stream.
  2. Identify and decode the special attachment that contains the TNEF stream.
  3. Extract all the attachments from the incoming message into MAPI attachments on the new MAPI message. The recovered filenames, or other identifying markers on the attachments, should be placed into the PR_ATTACH_TRANSPORT_NAME property of the new attachments so that the ExtractProps method can later associate the correct attachment with the attachment tags encoded in the message text.
  4. Create an OLE IStream object to wrap around the decoded TNEF stream and use that object along with the new MAPI message in a call to the OpenTnefStreamEx function.
  5. Call the ITnef::ExtractProps method to recover the nontransmittable properties on the message from the TNEF data stream.
  6. Call the ITnef::OpenTaggedBody method with the MAPI_CREATE and MAPI_MODIFY flags set. This call removes the attachment tags from the message text and converts them into attachment position information in the MAPI message.
  7. Deliver the message through the MAPI spooler.