Tue Mar 30, 2021 10:34 am
Hi..I'm using spire email 4.1.2 and I'm working on extract attachment from a msg file. The problem that I facing now is if the attachment is a msg file, after the extraction it become an invalid file because of the return attach.ContentType.Name is the filename without the extension, for other attachment such as pdf it return a filename with extension. Is there anyway that I can extract the msg attachment correctly?
https://imgur.com/a/5cFfi8Q - Code: Select all
mail = MailMessage.Load(file);
foreach (Attachment attach in mail.Attachments)
{
var target = path + Path.DirectorySeparatorChar + attach.ContentType.Name;
fs = File.Create(target);
attach.Data.CopyTo(fs);
fs.Dispose();
}
Here I also attached a sample file for you to test out.
Login to view the files attached to this post.