Is it possible to get attachment with EWS Managed API directly, without getting its containing EmailMessage first?
Something like:
FileAttachment attach = FileAttachment.Bind(ewsService, attachId);
I couldn't find any method for this.
Is it possible to get attachment with EWS Managed API directly, without getting its containing EmailMessage first?
Something like:
FileAttachment attach = FileAttachment.Bind(ewsService, attachId);
I couldn't find any method for this.
You can use the GetAttachments method of the ExchangeService Class https://msdn.microsoft.com/en-us/library/office/dn600509(v=exchg.80).aspx , this allows you to batch one or more GetAttachment requests together, for example:
FindItemsResults<Item> fItems = service.FindItems(WellKnownFolderName.Inbox,new ItemView(10));
PropertySet psSet = new PropertySet(BasePropertySet.FirstClassProperties);
service.LoadPropertiesForItems(fItems.Items, psSet);
List<Attachment> atAttachmentsList = new List<Attachment>();
foreach(Item ibItem in fItems.Items){
foreach(Attachment at in ibItem.Attachments){
atAttachmentsList.Add(at);
}
}
ServiceResponseCollection<GetAttachmentResponse> gaResponses = service.GetAttachments(atAttachmentsList.ToArray(), BodyType.HTML, null);
foreach (GetAttachmentResponse gaResp in gaResponses)
{
if (gaResp.Result == ServiceResult.Success)
{
if (gaResp.Attachment is FileAttachment)
{
Console.WriteLine("File Attachment");
}
if (gaResp.Attachment is ItemAttachment)
{
Console.WriteLine("Item Attachment");
}
}
}