Hi @Hielke Hoeve ,
Welcome to the Microsoft Q&A platform!
It sounds like you're facing quite a challenge transitioning from EWS to Microsoft Graph, especially when creating messages that include other messages as attachments without marking them as drafts. Let's try to step through this.
Based on your description, it seems like the main issue is that the attached message is being created as a draft. Here are some suggestions that may help:
- Make sure that the SingleValueExtendedProperties for both the root message and the attached message are set correctly. It looks like you've already tried this, but double-checking the property IDs and values may help.
- Make sure you're using the correct endpoints for creating messages and adding attachments. Your current approach seems correct, but here's a quick recap:
- Use POST /me/messages to create the root message.
- Use POST /me/messages/{message-id}/attachments to add attachments.
- When creating the attached message, explicitly set the isDraft property to false. This may help ensure that the message is not marked as a draft.
- Make sure that all required properties for the attached message are set correctly. Sometimes, missing properties can cause unexpected behavior.
Here is an example of how you might construct a request:
Create a root message
POST https://graph.microsoft.com/v1.0/me/messages
Authorization: Bearer {access_token}
Content-Type: application/json
{
"createdDateTime": "2024-11-12T08:49:36Z",
"lastModifiedDateTime": "2024-11-12T08:49:36Z",
"receivedDateTime": "2024-11-12T08:49:36Z",
"sentDateTime": "2024-11-12T08:49:36Z",
"hasAttachments": true,
"subject": "Root e-mail",
"body": {
"contentType": "text",
"content": "Root e-mail"
},
"parentFolderId": "X",
"sender": {
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
},
"from": {
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
}
],
"singleValueExtendedProperties": [
{
"id": "Integer 0x0E07",
"value": "1"
},
{
"id": "SystemTime 0x0039",
"value": "2024-11-12T08:49:36Z"
},
{
"id": "SystemTime 0x0E06",
"value": "2024-11-12T08:49:36Z"
}
]
}
Add an ItemAttachment
POST https://graph.microsoft.com/v1.0/me/messages/{message-id}/attachments
Authorization: Bearer {access_token}
Content-Type: application/json
{
"@odata.type": "#microsoft.graph.itemAttachment",
"name": "Attached Message",
"item": {
"@odata.type": "#microsoft.graph.message",
"subject": "E-mail as attachment",
"body": {
"contentType": "html",
"content": "E-mail as attachment"
},
"sender": {
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
},
"from": {
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
},
"toRecipients": [
{
"emailAddress": {
"name": "Hielke",
"address": "hielke@example.com"
}
}
],
"isDraft": false,
"singleValueExtendedProperties": [
{
"id": "Integer 0x0E07",
"value": "1"
},
{
"id": "SystemTime 0x0039",
"value": "2024-11-08T12:38:57Z"
},
{
"id": "SystemTime 0x0E06",
"value": "2024-11-08T12:38:57Z"
}
]
}
}
Please feel free to contact me for any updates. And if this helps, don't forget to mark it as an answer.
Best,
Jake Zhang