+1 vote

Please. Could you show me an example of how do I extract the contents of the winmail.dat file and save the archive?

by

1 Answer

0 votes

winmail.dat attachments (Content-Type: application/ms-tnef) are processed automatically.

You can turn this feature off by setting ProcessTnefAutomatically property to false:

MailBuilder builder = new MailBuilder();
builder.ProcessTnefAutomatically = false;

If you have eml date at hand use CreateFromEml method:

byte[] eml = ...
MailBuilder builder = new MailBuilder();
IMail email = builder.CreateFromEml(eml);

If you need to process an eml file on disk use CreateFromEmlFile method:

MailBuilder builder = new MailBuilder();
IMail email = builder.CreateFromEmlFile("c:\\email.eml");

All attachments, visual elements stored inside winmail.dat are extract4ed and put in standard collections:

var attachments = email.Attachments;
var visuals= email.Visuals;
var nonVisuals = email.NonVisuals;
var appointments = email.Appointments;

All mime objects extracted from winmail.dat have X-Tnef2Mime header set to true You can use MimeData.XTnef2Mime property to retrieve its value.

MimeData attachment = email.NonVisuals[0];
Assert.AreEqual(true, attachment.XTnef2Mime);

Also Html, Text and Rtf content are extracted and put in IMail.Text, IMail.Html and IMail.Rtf if those are not defined.

by (297k points)
...