0
votes

We are trying to convert from EWS into Microsoft Graph API , I saw that the basic "schema extensions" with api: GET - https://graph.microsoft.com/v1.0/me/messages

the response is:

{
  "value": [
    {
      "receivedDateTime": "datetime-value",
      "sentDateTime": "datetime-value",
      "hasAttachments": true,
      "subject": "subject-value",
      "body": {
        "contentType": "",
        "content": "content-value"
      },
      "bodyPreview": "bodyPreview-value"
    }
  ]
}

following the ask question:

Add custom headers and retrieve custom header using Microsoft Graph API

I want to insert some headers like EWS protocol following the picture below:

enter image description here

P.S:

I saw it is possible in beta version:

https://github.com/microsoftgraph/microsoft-graph-docs/blob/master/api-reference/beta/resources/internetmessageheader.md

How can I do it exactly ??

1

1 Answers

2
votes

The internetMessageHeaders property is read-only. You can't set arbitrary headers on an outgoing message directly via Graph.

With EWS, you had to set an extended property in the InternetHeaders property set. You could do the same thing via Graph using singleValueLegacyExtendedProperties with a little digging :).

First, we need the GUID for the InternetHeaders property set. From MS-OXPROPS, that value is 00020386-0000-0000-C000-000000000046. So following along with the instructions to create a single-value extended property, we come up with a property id like:

String {00020386-0000-0000-C000-000000000046} Name X-MY-COMPANY-INVOICE

Now I can modify the JSON payload I POST to the /sendMail endpoint to include this property with a value:

{
  "message": {
    "subject": "Meet for lunch?",
    "body": {
      "contentType": "Text",
      "content": "The new cafeteria is open."
    },
    "toRecipients": [
      {
        "emailAddress": {
          "address": "[email protected]"
        }
      }
    ],
    "singleValueExtendedProperties": [
      {
        "id": "String {00020386-0000-0000-C000-000000000046} Name X-MY-COMPANY-INVOICE",
        "value": "This is my value that I put here. Isn't it neat?"
      }
    ]
  }
}