0
我在我的應用程序中使用EWS服務。在我想要獲取現有電子郵件,然後將其轉換爲文件。我爲此使用以下代碼。如何從EWS獲取電子郵件時獲取MimeContent?
private ExchangeService _service = null;
internal EWSClient()
{
_service = new ExchangeService(ExchangeVersion.Exchange2010_SP1);
_service.Credentials = new WebCredentials(HandlerSettings.MailReceiverLogin, HandlerSettings.MailReceiverPassword);
_service.Url = new Uri(HandlerSettings.MailReceiverServer);
}
取電子郵件我使用綁定方法。
var completeEmailMessage = EmailMessage.Bind(_service, emailId);
var mimeContent = completeEmailMessage.MimeContent;
string tempFile = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString() + ".eml");
using (var fileStream = new FileStream(tempFile, FileMode.Create))
{
fileStream.Write(mimeContent.Content, 0, mimeContent.Content.Length);
}
在這裏,我得到異常completeEmailMessage.MimeContent;一片空白。
我應該使用哪種方法來獲取具有MimeContent的完整電子郵件?