I found several questions here about detecting mail status in various mail servers, but still it's unclear how to do it using Outlook REST API.
In documentation we can see the response for request:
GET https://graph.microsoft.com/v1.0/me/messages/AAMkADhMGAAA=
But it seems like the answer doesn't have a field, which contains such information. I also looked into request for headers:
https://graph.microsoft.com/v1.0/me/mailfolders/inbox/messages?$select=subject,internetMessageHeaders
Unfortunately, there was no header like X-Failed-Recipients
.
Are there any ways to get delivery status and/or failed recipients using Outlook API?
My approach to this was getting message details and the internetMessageHeaders as you have done.
First I check for header Content-Type
value multipart/report
which denotes a DSN (delivery status notification), see RFC
3461.
GET https://graph.microsoft.com/v1.0/me/messages/<id>?$select=internetMessageHeaders
Then I get the toRecipients
property of the message which contains the
email address of the recipient that failed.
GET https://graph.microsoft.com/v1.0/me/messages/<id>
Note:
toRecipients
always contains the value of the failed recipient, but so far I have yet to find an example to the contrary.