I am trying to insert a message directly into a user's inbox using the Graph API /messages endpoint.
I am calling this endpoint:
https://graph.microsoft.com/v1.0/users/{userid}/mailFolders/inbox/messages
My request looks like this:
{
"body": {
"contentType": "html",
"content": "<a href='https://google.com'>test</a>"
},
"sender": {
"emailAddress": {
"name": "test",
"address": "someuser@test2.com"
}
},
"from": {
"emailAddress": {
"name": "test",
"address": "someuser@test2.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Some User",
"address": "someuser@test.com"
}
}
],
"isDraft": false
}
It does put the message in the user's inbox, and it does NOT show up in the drafts folder. However, when I open the message in the inbox, it appears to be a draft. How can I directly insert a message into a users' inbox?
You need to set the pidtagmessageflags singleValueExtendedProperties https://learn.microsoft.com/en-us/office/client-developer/outlook/mapi/pidtagmessageflags-canonical-property to either 1 (if you want the message marked as read also) or 4 (for unread). eg
{
"body": {
"contentType": "html",
"content": "<a href='https://google.com'>test</a>"
},
"sender": {
"emailAddress": {
"name": "test",
"address": "someuser@test2.com"
}
},
"from": {
"emailAddress": {
"name": "test",
"address": "someuser@test2.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Some User",
"address": "someuser@test.com"
}
}
],
"singleValueExtendedProperties": [
{
"id": "Integer 0x0E07",
"value": "4"
}
]
}