We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Detecting embedded messages in emails

Hi,


We receive emails and often few of them have embedded EML or MSG files. In most cases, the attachment doesn’t have any indication if the attachment is an email or normal file type. Can you please suggest some method for achieving this?

Hi Robert,

Following sample code detects the internal emails and saves them as EML file on disc. Please give it a try and share the feedback.

String path = @"\";
var mail = MailMessage.Load(path + "sample.eml", new EmlLoadOptions());
String attName = null;

foreach (Aspose.Email.Mail.Attachment attch in mail.Attachments)
{
    if (attch.ContentType.MediaType == "message/rfc822")
    {
        attName = path + attch.Name + ".eml";
        attch.Save(attName);
    }
}