Save mail to msg file using EWS API

后端 未结 8 2179

I\'m using Exchange Web Services Managed API 1.1 to connect to Exchange server 2010 and then find out new emails received. Now I want to save a copy of the .msg file to a fo

8条回答
  •  猫巷女王i
    2020-11-28 10:25

    This suggestion was posted as a comment by @mack, but I think it deserves its own place as an answer, if for no other reason than formatting and readability of answers vs. comments.

    using (FileStream fileStream = 
        File.Open(@"C:\message.eml", FileMode.Create, FileAccess.Write)) 
    { 
        message.Load(new PropertySet(ItemSchema.MimeContent)); 
        MimeContent mc = message.MimeContent; 
        fileStream.Write(mc.Content, 0, mc.Content.Length); 
    }
    

提交回复
热议问题