how can I get the MIME-Content from an ItemAttachment (Message) attached to an email in C#?
In the Graph Explorer it is possible to get the MIME-Content:
https://graph.microsoft.com/v1.0/users/{id}/messages/{id}/attachments/{id}/$value
The Graph Explorer suggests to use ".Content" in C#. But if I try this, the compiler says:
Error CS1061 'IAttachmentRequestBuilder' does not contain a definition for 'Content' and no accessible extension method 'Content' accepting a first argument of type 'IAttachmentRequestBuilder' could be found (are you missing a using directive or an assembly reference?)
C# code:
private async Task<ItemAttachment> GetItemAttachment(string id)
{
ItemAttachment itemAttachment = null;
var attachment = await GraphServiceClient
.Users[CurrentUser.Id]
.Messages[CurrentMessage.Id]
.Attachments[id]
.Content
.Request()
.GetAsync();
itemAttachment = attachment as ItemAttachment;
return itemAttachment;
}
What is the correct way to get the MIME-content of an attachment in C#?