I'm coding an Outlook add-in, that is written using Visual Studio and VSTO, that can automatically change the format of outbound emails to HTML:
I'd doing the following:
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
//Add event handler for when emails are sent out
this.Application.ItemSend += new Microsoft.Office.Interop.Outlook.ApplicationEvents_11_ItemSendEventHandler(onItemSend);
}
private void onItemSend(object Item, ref bool Cancel)
{
//Called when email is sent
Outlook.MailItem objMailItem = (Outlook.MailItem)Item;
//Set message format as HTML
objMailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
}
I'm noticing that my onItemSend is called, and if the original email that is being sent was composed as plain-text, that email still arives at the destination as plain-text in despite of my change there. I even tried reading objMailItem.BodyFormat back and it says olFormatHTML.
What am I doing wrong?

In addition to setting the
BodyFormatproperty, you need to set the correct HTML markup for your message body - the HTMLBody property sets a string representing the HTML body of the specified item. Setting theHTMLBodyproperty will always update theBodyproperty immediately.