I have a MimeMessage which contains a winmail.dat attachment of type application/ms-tnef.
I believe this is an RTF formatted email, which is sent from Outlook client. I tried parsing it with the tnefpart but I'm running into the following error.
Here is my function:
ProcessMimeMessage(MimeMessage plainMime)
{
foreach (var attachment in plainMime.Attachments)
{
if (attachment.GetType() == typeof(MimeKit.Tnef.TnefPart))
{
ReportStatus("Processing Tnef Part (RTF Message): ");
MimeKit.Tnef.TnefPart tnefPart = (MimeKit.Tnef.TnefPart)attachment;
try {
MimeMessage mimeMessage = tnetPart.ConvertToMessage();
} catch (Exception ex) {printexception(ex);}
}
}
}
This is the exception that is thrown from ConvertToMessage
Invalid addr-spec token at offset 0
at MimeKit.InternetAddress.TryParseAddrspec(Byte[] text, Int32& index, Int32 endIndex, Byte[] sentinels, Boolean throwOnError, String& addrspec, Int32& at)
at MimeKit.MailboxAddress.set_Address(String value)
at MimeKit.Tnef.TnefPart.EmailAddress.TryGetMailboxAddress(MailboxAddress& mailbox)
at MimeKit.Tnef.TnefPart.ExtractMapiProperties(TnefReader reader, MimeMessage message, BodyBuilder builder)
at MimeKit.Tnef.TnefPart.ExtractTnefMessage(TnefReader reader)
at MimeKit.Tnef.TnefPart.ConvertToMessage()
Thanks