MimeEntity crawling and the winmail.dat problem

0 votes
asked Dec 29, 2012 by David Neubauer (180 points)
edited Dec 29, 2012

We'd like to use the MimeEntity tree to crawl the entire message for known file types we can process. This is because we are getting a lot of incoming emails with attached .EML files that contain files we need to process. Trouble is that it returns un-parsable winmail.dat files (20 yr old TNEF Format).

Now the MailMessage.Attachments collection does not have this problem. So it must contain a usable TNEF parser in there and I was wondering if maybe this was exposed somewhere so that I could use it when crawling the MimeEntity tree.

Any thoughts?

:)

Applies to: Rebex Secure Mail
commented Dec 29, 2012 by Lukas Pokorny (124,570 points)
edited Dec 29, 2012

TNEF/winmail.dat format is only supported by MailMessage object, there is no support for it in MimeEntity/MimeMessage - those objects are MIME only. At the moment, we have no public API for parsing raw winmail.dat files, but the solution you came up with is perfectly OK.

1 Answer

+1 vote
answered Dec 29, 2012 by David Neubauer (180 points)
edited Dec 29, 2012

Oh boy, I tripped and stumbled over a solution. Is there a better way to code this?

                    if (top.Name == "winmail.dat")
                    {
                        MimeMessage mime = top.ToMessage();
                        MailMessage msg = (MailMessage)mime;
                        foreach (Attachment attachment in msg.Attachments)
                        {
                            MimeEntity ent = new MimeEntity();
                            ent.ContentType = attachment.ContentType;
                            ent.SetContent(attachment.GetContentStream());
                            ent.Name = attachment.FileName;
                            nodes.Add(ent);
                        }
                    }
                    else
                    {
                        nodes.Add(top); 
                    }
commented Dec 29, 2012 by Lukas Pokorny (124,570 points)
edited Dec 29, 2012

This actually looks like the best solution! At least with the current version of Rebex Secure Mail.

...