Reputation: 2375
I'm using Microsoft Graph to pull email data from a mailbox. When I get the content, I find embedded images with content like so:
<img id="_x0000_i1029"
width="1366"
height="672"
data-outlook-trace="F:1|T:1"
src="cid:[email protected]"
style="width:14.2291in; height:7.0in">
When the property hasAttachments
is true, I look for images that match and replace the content and it works great. The problem is I see embedded image tags like this on messages where hasAttachments
is false.
Where can I get the image data Graph says the Message has no attachments but there clearly are embedded images?
Note that the image renders in Outlook for the Web with a tag like:
<img data-imagetype="AttachmentByCid"
originalsrc="cid:[email protected]"
data-custom="AAMkADY1YjgxM2Y4LTE5NTUtNDBjMy1iZDY0LWIzN..."
naturalheight="672"
naturalwidth="1366"
src="https://attachments.office.net/owa/[email protected]/service.svc/s/GetAttachmentThumbnail?id=AAMkADY1YjgxM2Y4LTE5NTUtNDBjMy1iZDY0LWIzN...&thumbnailType=2&owa=outlook.office365.com&scriptVer=2019031102.10&X-OWA-CANARY=kKWSUkiFW0WjlPXXXXXXXXX.&token=eyJhbGciOiJSU...&animation=true"
id="_x0000_i1029"
data-outlook-trace="F:1|T:1"
style="width: 1024.49pt; height: 504pt; cursor: pointer;"
crossorigin="use-credentials" >
Upvotes: 7
Views: 4677
Reputation: 255
Using Microsoft Graph API you can get all attachments of a mail:
GET https://graph.microsoft.com/v1.0/me/messages/{id}/attachments
or
GET https://graph.microsoft.com/v1.0/users/{id | userPrincipalName}/messages/{id}/attachments
When you get all attachments you can check property isInline
to find embedded images.
You can get attachments even if an email has property hasAttachments
set to false, because that property is related to not inline attachments.
Upvotes: 8