Mail Message createReply doens't save custom headers

Noa Grinberg 1 Reputation point
2022-09-13T10:28:46.387+00:00

Hi!
I'm using Graph 1.0 Mail Message API to create drafts, sometimes as a new thread and sometimes as a reply of an existing thread.
Using these 2 rest APIs:
POST /messages: https://learn.microsoft.com/en-us/graph/api/user-post-messages?view=graph-rest-1.0&tabs=http. (create draft message)
POST /messages/{id}/createReply : https://learn.microsoft.com/en-us/graph/api/message-createreply?view=graph-rest-1.0&tabs=http (create draft to reply)

I need to add a custom header to the email, and I add it in the JSON in internetMessageHeaders.
In POST /messages (create draft) custom header added to the draft.
In POST /messages/{id}/createReply same header is not added to the draft.
(I check it on the received email after sending the draft).

The Json I supply in POST looks like:
{"subject":".."
,"body":{"contentType":"HTML","content":"...."},
"toRecipients":[...],
"ccRecipients":[...],
"bccRecipients":[...],
"internetMessageHeaders":[{"name":"x-my-custom-header","value":"My Custom Value"}]
}
Any idea?
Or suggestion how I can create a reply draft with a custom header?
Thanks, Noa

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,779 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Glen Scales 4,436 Reputation points
    2022-09-14T00:54:58.387+00:00

    As long as your header has been provisioned in a mailbox https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-provision-x-headers-by-using-ews-in-exchange (eg a least is been used once before) you should be able to use SingleValueExtendedProperties to do that but not in the initial createReply request eg this is what works for me

    {  
        "SingleValueExtendedProperties": [  
            {  
                "Id": "String {00020386-0000-0000-C000-000000000046} Name x-my-custom-header",  
                "Value": "Some Value"  
            }  
        ]  
    }  
    

    240785-image.png

    then you patch the draft message with your extended property for the x-header

    240786-image.png

    and then Send and your x-header should get added

    240804-image.png

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.