Email as attachment


Attached email is not available in AttachmentFiles property of the HigLabo.Mime.MailMessage object. From outlook I send an email with another email added as attachment (drag and drop). This is send to POP3 mailbox. When I read this email then attached email is not available on AttachmentFiles list. I have attached sample email. When I read it and check AttachmentFiles only attachment.txt file is available.

file attachments


higty wrote May 14, 2015 at 12:17 AM


Could you upload raw message text?
I could not open your .msg file.

wrote May 14, 2015 at 9:07 AM

coraln wrote May 14, 2015 at 9:07 AM


I uploaded this message as .txt file. After download please change extension to .eml.

higty wrote May 20, 2015 at 7:56 AM

I'll check with it!!

higty wrote May 20, 2015 at 8:12 AM

I found that your mail used Content-Type=message/rfc822 and I don't define the behavior about it.
I'll fix library to treat rfc822 feature.

Please wait for some days...it may be next week.

higty wrote May 20, 2015 at 9:08 AM

Can you use AllFiles property alternatively?

coraln wrote May 20, 2015 at 1:22 PM

I am using Contents property and check Content-Type=message/rfc822 to get additional attachments that are not on AttachmentFiles list.

But I don't know should I distinguish email from attached email. Currently I assume that this first Content is always main email. Can you confirm that mail email is always first on Contents list?

higty wrote May 26, 2015 at 4:18 AM


I solved your problem.
I Added MailMessage propety to MimeContent class.
This property return MailMessage object if ContentType is fomat as "message/rfc822".
You can get your attached file by this property.
Or you can also get by TransferedMailMessages property of MailMessage object.
I tested your mail by below code.
var mailText = File.ReadAllText(Environment.CurrentDirectory + "\\TestData\\Mail_CodePlex_21851.txt");
MimeParser parser = new MimeParser();
var mg = parser.ToMailMessage(mailText.UnifyLineFeed());

Assert.AreEqual(mg.AttachmentFiles.Count(), 1);
var messages = mg.TransferedMailMessages.ToList();
Assert.AreEqual(messages.Count, 1);
var tmg = messages[0];
Assert.AreEqual(tmg.Subject, "Inner email subject");
You can get fixed version from GitHub.