forked from OfficeDev/ews-managed-api
-
Notifications
You must be signed in to change notification settings - Fork 49
Open
Description
Hello!
I'm having a hard time downloading attachments.
The below code never downloads an attachment:
private Dictionary<string, Stream> DownloadAttachments(EmailMessage message)
{
var result = new Dictionary<string, Stream>();
var pdfAttachments = message.Attachments.Where(a => a.ContentType.Equals("application/pdf", StringComparison.OrdinalIgnoreCase));
Log.Debug($"{pdfAttachments.Count()} attachment(s) found.");
foreach (FileAttachment attachment in pdfAttachments)
{
var ms = new MemoryStream(attachment.Size);
attachment.Load(ms);
result.Add(attachment.Name, ms);
}
return result;
}
No error is thrown; the attachment.Content property is null, and the length of the MemoryStream is 0. The metadata for the attachment is downloaded correctly though. I can obtain attachment filename, size, and content type.
Please note, that the EmailMessage message argument is already bound to an ExchangeService by the calling method using the ItemSchema.Attachments amongst other schemas.
Any help/insights would be greatly appreciated!
Metadata
Metadata
Assignees
Labels
No labels