问题
I have a web services which allows me to send messages via office 365 hosted service. So far all works fine. But there is cases when an email bounces and I would like to mark that email bounced / undelivered in my CRM. In some cases the remote host returns undelivered: and the original subject as well as the email address it was send to. In case of google addresses this is not the case. So I can’t parse the subject to get the original message. Is there anywhere in the body or header any info which I could use to find the originating message that was not delivered ?
回答1:
The In-reply-to header of the bounce message should contain the original InternetMessageId of the Message you Sent message. You can either use the InternetMessageHeaders or get the SingleValueExtendedProperties property for that header eg
https://graph.microsoft.com/v1.0/me/MailFolders('Inbox')/messages/?$select=ReceivedDateTime,Sender,Subject,IsRead,inferenceClassification,InternetMessageId,parentFolderId,hasAttachments,webLink&$Top=10&$expand=SingleValueExtendedProperties($filter=Id eq 'String 0x1042')
Encoded version for the Graph Explorer preview
https://graph.microsoft.com/v1.0/me/MailFolders('Inbox')/messages/?$select=ReceivedDateTime%2cSender%2cSubject%2cIsRead%2cinferenceClassification%2cInternetMessageId%2cparentFolderId%2chasAttachments%2cwebLink&$Top=10&$expand=SingleValueExtendedProperties(%24filter%3dId+eq+%27String+0x1042%27)
来源:https://stackoverflow.com/questions/61336835/how-to-trace-back-bounced-messages