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

Free Support Forum - aspose.com

Detect msg attached files without extension

Hello,


is possible to detect an attachment file without extension if is an valid msg or eml file?

Hi,


Thank you for posting your inquiry.

Yes, you can find out about the attachment message type if it is a valid MSG or EML using the content type of the attachment as shown in the following sample code.

Code:

string dir = “EMAIL_558944\”;
string[] files= Directory.GetFiles(dir, “*.msg”);
foreach (string file in files)
{
MailMessage msg = MailMessage.Load(file);

foreach (Attachment att in msg.Attachments)
{
if (att.ContentType.MediaType.Equals(“message/rfc822”))
att.Save(dir + att.Name + “.eml”);
}
}