2
獲得一個EmailMessage附件我這裏有這樣的代碼,我檢索使用EWS通過FileStreamResult
Attachment attachment = message.Attachments.Single(att => att.ContentId == Request.QueryString["cid"]);
attachment.Load();
FileAttachment fileAttachment = attachment as FileAttachment;
fileAttachment.Load();
byte[] bytes = fileAttachment.Content;
Stream theMemStream = new MemoryStream();
theMemStream.Write(bytes, 0, bytes.Length);
return new FileStreamResult(theMemStream, attachment.ContentType);
電子郵件是在Exchange服務器上的附件,我可以下載的文件就好了但是他們被損壞。 ..有什麼我失蹤?
顯然我忘了theMemStream.Seek(0,SeekOrigin.Begin);這就是爲什麼如此你的權利...謝謝... – Sevki 2010-08-06 10:59:53
@Sevki這是一個經典。我也錯過了。 :) – bzlm 2010-08-06 17:49:20