microsoftgraph / aspnet-snippets-sample

A repository of code snippets that use Microsoft Graph to perform common tasks such as sending email, managing groups, and other activities from an ASP.NET Core MVC app. This sample uses the Microsoft Graph .NET Client Library to work with data, and the Microsoft Identity Web Library for authentication on the Microsoft identity platform v2.0 endpoint.
MIT License
189 stars 101 forks source link

Image src attribute in email body using microsoft graph #42

Closed glensouza closed 4 years ago

glensouza commented 6 years ago

Is there sample code out there for getting an Office 365 email body with the embedded image using Microsoft Graph? So far I've only been able to get an image tag that the "src" attribute does not reflect anything that would display the image that looks something like this: <img src="cid:image001.jpg@01D3E60C.5A00BC30"> and of course, that does not display any images.

jasonjoh commented 4 years ago

I know this is an old issue, but I wanted to provide an answer anyway.

That format in the src attribute indicates that the image is attached to the message. To render it, you must get the attachment that has that CID stamped on it and insert it in the appropriate place. The CID will be in the contentId property on the attachment.

See https://docs.microsoft.com/graph/api/resources/fileattachment?view=graph-rest-1.0