I send the description my team is having with the json integration with Office API 365.
We want to send an email with inline attachments through the JSON API.
With that objective, what we are doing:
What is our issue with the API?
We are unable to set the "ContentType" properties when we submit the attachments to the Office API 365. Despite the "ContentType" we send, it is always null.
We are using the following API: POST https://outlook.office365.com/api/v1.0/me/messages/{message_id}/attachments
That's the reason we think that despite the inline image then it is found in the body, it cannot be displayed because the contenttype it is not set correctly.
Please give us some direction.
The ContentType shouldn't be an issue. What is important is that you set the ContentId property to a value, then use that value in your cid link in the message body. Here's what worked for me:
POST /Me/folders/drafts/messages
{
"Subject": "Inline image test",
"Body": {
"ContentType": "HTML",
"Content": "<html><body><strong>There should be an image here:</strong><p><img src=\"cid:my_inline_attachment\"></p></body></html>"
}
}
Notice the cid:my_inline_attachment
bit.
Then do:
POST /Me/messages({message_id})/Attachments
{
"@odata.type": "#Microsoft.OutlookServices.FileAttachment",
"Name": "th.jpg",
"IsInline": true,
"ContentId": "my_inline_attachment",
"ContentBytes": {base64-encoded contents of jpeg}
}
Notice the "ContentId": "my_inline_attachment"
line in the attachment JSON. Hope that helps!