從NuGet 下載
using (var msg = new MsgReader.Outlook.Storage.Message("d:\\testfile.msg"))
{
var from = msg.Sender;
var sentOn = msg.SentOn;
var recipientsTo = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.To, false, false);
var recipientsCc = msg.GetEmailRecipients(MsgReader.Outlook.RecipientType.Cc, false, false);
var subject = msg.Subject;
var htmlBody = msg.BodyHtml;
// etc...
//取附檔
foreach(MsgReader.Outlook.Storage.Attachment attach in msg.Attachments)
{
byte[] attachBytes = attach.Data;
FileStream attachStream = File.Create(attach.FileName); //attach.FileName 存檔路徑
attachStream.Write(attachBytes, 0, attachBytes.Length);
attachStream.Close();
}
}
留言列表