I can retrieve the emails and attachments using this code:
var emails = await graphServiceClient.Users["[email protected]"].MailFolders["Inbox"].Messages
.Request()
.Top(10)
.Expand("attachments")
.Select("subject,receivedDateTime,from,attachments")
.GetAsync(cancellationToken);
However I'm not interested in the contents for the attachments (expanding the attachments is around 3x slower). Is it possible to get just the attachment names in a single call? If I leave out the .Expand then the Attachments property is null.
CodePudding user response:
Try to use $select in Expand to return only selected properties for expanded property.
var emails = await graphServiceClient.Users["[email protected]"].MailFolders["Inbox"].Messages
.Request()
.Top(10)
.Expand("attachments($select=name)")
.Select("subject,receivedDateTime,from,attachments")
.GetAsync(cancellationToken);
