0 votes
by (180 points)
edited

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
by (148k points)
edited

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
by (180 points)
edited

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); 
                    }
by (148k points)
edited

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

...