close

從NuGet 下載

image

 

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();
                }


}

arrow
arrow
    文章標籤
    C#
    全站熱搜

    JosephChou 發表在 痞客邦 留言(0) 人氣()