"To" header not visible in the header of the undelivered/bounced emails
Hi,
If somebody can help here. We are monitoring a few Office365 mailboxes and read their emails. Apart from reading email subject and body, we also see what was present in the "To" header for the email and based on that we are applying certain business rules. Recently we encountered an issue where we are not able to find the "To" recipient for emails which bounced back due to delivery failure. We are using Mailkit IMAP C# library to read the emails so my questions are:
- Could it be issue with the Mailkit IMAP library that it is unable to find the "To" header in the undelivered/bounced emails?
- We also used Microsoft Graph API to test the same emails and found out that although the "To" header is present in those emails but the value shown is not correct. For example, let's say we are monitoring a mailbox sender@abc.com and using the same we sent an email to recipients@xyz.com which bounced back as a delivery failure to sender@abc.com (which we are monitoring) so in this case, the "To" header shown using Microsoft Graph API is recipients@xyz.com where as it should be shown as sender@abc.com because this is where this email came back. I hope i am able to explain it properly here.
Is someone able to help here on these points that why
- we are not able to see the "To" header at all using Mailkit IMAP library
- when using Microsoft Graph API, it shows the correct "To" address
Additional information - When we check the "Internet Headers" of the same undelivered email in the Outlook, it actually shows the "To" header with the correct value (so in the example i have given in point # 2 above, it actually shows sender@abc.com as the "To").
So another question is when the "Internet headers" shows up the actual email address then why it is not being returned using the Microsoft Graph API?