Recently I came across a case where the requirement was to send an email (using Outlook Object Model) consisting of both HTML and Plain Text body, with the idea being that, based on the View set in outlook, the appropriate body will be chosen. The cause for setting multiple bodies was that, when an email containing image icons are rendered in plain text view, additional URLs were added in the place of the image icons which made the email look clumsy!
Digging further into the issue made me try some troubleshooting to check what exactly is happening. The first test was performed using Outlook Object model with the HTML body format set. Result observed was that for HTML view, the HTML body content was displayed along with the formatting while for Plain text view, only the HTML body content was displayed without any formatting. Further, test performed using System.Net.Mail with the AlternateView set, proved that Exchange will only store one body in one format and does not support having multiple bodies on a message.
The behavior observed is expected and by design. As per the protocol document, Exchange prefers a certain format, “text/HTML”. If there is an HTML body part it will be chosen as the Primary Message Text and that is what is converted to MAPI. When a client asks for PR_BODY (i.e. plain text) it will be converted as per “Best Body” logic.
As a simple work around, rather than referencing external images for the image icons, it is suggested to add them as attachments and reference them in HTML.
Reference Links :
· Selecting the Primary Message Text MIME Element : https://msdn.microsoft.com/en-us/library/gg709700%28v=exchg.80%29.aspx
· Determining Which MIME Element Is the Message Body : https://msdn.microsoft.com/en-us/library/gg672007%28v=exchg.80%29.aspx
· HTML Text Message Body Without Inline Attachments : https://msdn.microsoft.com/en-us/library/ee238059%28v=exchg.80%29.aspx
· Best Body Algorithm : https://msdn.microsoft.com/en-us/library/hh369831%28v=exchg.80%29.aspx
· Forum link that has a discussion thread for a similar issue https://social.msdn.microsoft.com/Forums/office/en-US/0c490364-c6f7-40cf-9f6f-b90aea443cda/outlook-email-text-or-html-format-for-recepient?forum=outlookdev
Kamala Payyapilly Thiruvenkatanathan [MSFT]