I have the following code:
var graphServiceClient = GraphClientFactory.GetGraphServiceClient(config.ClientId, config.Authority, config.Scopes);
MailMessagePage = await graphServiceClient.Me.MailFolders.Inbox.Messages
.Request()
.Expand("attachments")
.GetAsync();
foreach (var mm in MailMessagePage)
{
foreach (var a in mm.Attachments)
{
}
}
This code is successfully downloading the Inbox Messages and the Inner foreach loop is enumerating through the attachments collection. Here is a example:
What is not included is the actual attachment data. Does anyone have an example of downloading the actual attachment data?
Thanks
Based on the suggestions from Darrel I implemented the following.
var outlookItem = await builder.Request().GetAsync();
Is returning the Metadata for the attachment bu not the attachment itself. I am after the data.
MailMessagePage = await graphServiceClient.Me.MailFolders.Inbox.Messages
.Request()
.Expand("attachments")
.GetAsync();
foreach (var mm in MailMessagePage)
{
foreach (var itemAttachment in mm.Attachments)
{
if(itemAttachment is ItemAttachment)
{
var builder = new ItemAttachmentRequestBuilder(graphServiceClient.Me.Messages[mm.Id].Attachments[itemAttachment.Id].RequestUrl, graphServiceClient);
var outlookItem = await builder.Request().GetAsync();
}
}
}