0

I have an application which can create emails with HTML formatting and embedded images. This works by adding an "attachments" section in the message create json like so:

"attachments": [
    {
        "@odata.type": "#microsoft.graph.fileAttachment",
        "name": "image.png",
        "contentId": "48132221018252368",
        "isInline": true,
        "contentType": "image/png",
        "contentBytes": "iVBORw0KGgoAAAA..."
    }
]

However using a similar method when creating a calendar event does not work - there is no attachment if I query the event for attachments and the event view in Outlook shows a broken image.

So I tried adding the attachment after the event is created and I get a 201 success response as expected, with appropriate attachment data. But the attachment is still not there if I query for it.

So I tried adding the attachment by hand (i.e. not in my app) using the MS Graph API explorer but providing exactly the same request json as my app and the attachment is added as required and shows correctly in the event body.

A strange thing also happens if I create the attachment using my app (and it doesn't show), but I then delete the event through the API - the cancellation notice in Outlook shows my embedded image as expected.

What am I doing wrong?

  • Why can't I add the attachment for an event in the same way as I do for an email?
  • Why does the attachment get added correctly when done manually? Do I have to wait for some time (how long?) before I add it in my app?
  • Why does the attached image show correctly when the event is deleted?

Note: I have only used very small images for testing, so the problem shouldn't be due to the file size being >3MB and therefore requiring a separate createUploadSession

1 Answer 1

0

The one step process where you create an inline attachment and the event in one request looks like its buggy as I can reproduce the same issue. As a workaround doing a 3 step process seems to work okay eg first create the event with no attendees or body. Step 2 add the attachment, step 3 patch the attendees and the body.

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the response. I think I'm currently trying 2 steps that are not the same as yours. I create the fully populated event and then add the attachment. You seem to suggest creating a blank event, adding the attachment and then updating the event afterwards. Is that correct?
Yes there's always been problem in EWS around when you send a meeting with an Attachment you need to create the attachment first before adding the attendees else you end up with a missing attachments. I think this it probably the same issue or slightly different but in general always add the attendees after everything is good with meeting. If 2 steps works that should be okay but make sure you verify both organizer and attendees are the same as that has been an issue in the past.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.