Outlook can't show body of TNEF email exported from Exchange transport agent

512 Views Asked by At

I'm exporting emails by Exchange 2016 transport agent and saving them to disk. Outlook successfully opens all the emails, resolve headers, but ts is not able to show body of messages sent from Outlook client. Type is:

Content-Type: application/ms-tnef; name="winmail.dat"

Other types (MIME etc.) are OK. Exported messages do contain body. I'm able to convert it to .msg and all works after this operation. Why is this happening?

Email export method:

  using (var stream = new MemoryStream())
  {
    email.MimeDocument.WriteTo(stream);
    storageManager.SaveStreamToFile(stream, path);
    size = stream.Length;
  } 

I've alredy tried using various events of transport pipeline (https://technet.microsoft.com/en-us/library/bb125012(v=exchg.150).aspx). This question was asked on different forums, but there is no real answer. I'll provide an example of email if you want me to.

1

There are 1 best solutions below

1
On

The TNEF (Transport Neutral Encapsulation Format) is a proprietary email attachment format used by Microsoft [more technical infos here]. If you do not handle that correctly you will end up in an winmail.dat as an attachment [explained here].

To get the content from the winmail.dat you have multiple options now:

  1. Try to parse it like explained here.
  2. Use Yerase's TNEF Stream Reader [maybe the best option]
  3. Use OpaqueMail [might not work with your transport agent approach]
  4. Try to use the TnefReader Class
  5. Rebuild your solution and use Exchange EWS (= Exchange Web Services)