Q:

How can I get the FileAttachment from a Message instead of the Attachment

First of all, thank you for taking the time to read my question!
I need to retrieve the 'ContentByte' of an attachment of a message.
I use the Microsoft.Graph SDK for dotnet.
I retrieve a message, then I take the Message.Body.Content (is html) and show it in an Iframe. In order to show the attachments (cid:...) I have to get them in the Message.Attachments. But there is my problem. The mail attachments have a FileAttachment type with a 'ContentByte' property that I can use to show the attachments. The problem is that the SDK doesn't use the type 'FileAttachment' for Message.Attachments but 'Attachment', which doesn't have a 'ContentByte' property.
Here is my code:
Message data = await graphClient.Me
                .Messages[messageId]
                .Request().GetAsync();

and
var base64 = message.Attachments.Where(c => c.ContentId == contentId).ContentByte;

When I explore 'data' with the debugger I can see all the fields from the FileAttachment with all the correct data. But when I try to access it with the second line I get a red line under 'ContentId' because the property doesn't exist for an attachment.
Is this a bug, a mistake in the 'Message' class or do I have to specify somewhere that I want to keep the 'FileAttachment' type?
Thank you!

A:

This is expected behavior since Message.Attachments returns the collection of Attachment type.
To get the list of file attachments, filter could be applied by FileAttachment type via OfType Linq method:
//request message with attachments
var message = await graphClient.Me
      .Messages[messageId]
      .Request().Expand("Attachments").GetAsync();
//filter by file attachments and return first one
var fileAttachment = message.Attachments.OfType<FileAttachment>()
      .FirstOrDefault(a => a.ContentId == contentId);

if (fileAttachment != null)
{
     var base64 = fileAttachment.ContentBytes;
     //...
}

