0

I'm trying to retrieve emails using Microsoft Graph(and the Microsoft Graph SDK) and i'm running into the following problem : when the email has another Outlook message attached to it and that message also has attachments, i'm unable to get them.

I'm able to retrieve the attached message with the following query, but I can't do a second expand on attachments as I'm already doing one to get the OutllokItem(message)

/v1.0/users/<UserName>/messages/<MessageId>/attachments/<AttachmentID>?$expand=microsoft.graph.itemattachment/item

Is this possible at all ? Thanks in advance.

Maxime Laflamme
  • 3,786
  • 2
  • 11
  • 12

1 Answers1

1

For anyone looking for a solution, there's a feature currently available on beta only that allows you to get the whole message in Mime text format.

To get an attachment

/beta/users/<UserName>/messages/<MessageId>/attachments/<AttachmentID>/$value

To get the full initial message :

/beta/users/<UserName>/messages/<MessageId>/$value

See https://learn.microsoft.com/en-us/graph/api/attachment-get?view=graph-rest-beta&tabs=cs for details

Maxime Laflamme
  • 3,786
  • 2
  • 11
  • 12
  • I saw this in the API - has it been implemented in the SDK yet? I tried var attachmentFile = graphClient.Users[recipientId].Messages[message.Id].Attachments.Request().GetAsync().Result; but can't find a way to use the "$value" to get the contents of the attachment. – Mike Jul 02 '20 at 14:45
  • 1
    I haven't touched this in a while but when I used it, it was not. I used direct http requests to get them. – Maxime Laflamme Jul 02 '20 at 18:04
  • Thanks @Maxime - I implemented that way – Mike Jul 09 '20 at 20:22