+1 vote

HI Guys,

I am not able to convert .eml attachment to mime type using MsgCoverter. getting following exception -

"Invalid Compount File signature."

Code snippet -

using (MsgConverter converter = new MsgConverter(attachment.GetMemoryStream()))
{
    if (converter.Type == MsgType.Note)
    {
        IMail innerEmail = converter.CreateMessage();
        string innerEmailContent = innerEmail.Html;
        foreach (MimeData attachmentInner in email.Attachments)
        {
            byte[] filedataInner = attachmentInner.Data;
            Attachment atInner = new Attachment();
            atInner.Filename = attachmentInner.SafeFileName;
            atInner.EventID = 0;
            atInner.CID = attachmentInner.ContentId;
            atInner.File = filedata;
            eml.Email_Attachment.Add(atInner);
            eml.Event.HasAttachment = true;
        }
    }
}

please help me on this.

Thanks !

by

1 Answer

0 votes
 
Best answer

I'm not sure what you are trying to do.
MsgConverter class is for converting msg files (outlook) to eml/MIME
(RFC-2822) structure/file.

"Invalid Compount File signature." means that the data you are trying to process are not msg file (incorrect file signature).

If you want to load and parse eml file use MailBuilder class:

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

-or-

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

If your attachment is RFC822 MIME object. Cast it to MimeRfc822 and use its Message property:

MimeRfc822 mime = mail.Attachments
    .Find(x => x.FileName == "email.eml") as MimeRfc822;

IMail inner = mime.Message;
by (301k points)
...