0
votes

Is there a way to convert some HTML to the Outlook (2010) mail format found in Actions -> Other Actions -> View Source by using C#?

I am sending email using System.Net.MailMessage class with HTML table in the Body to Outlook and Lotus Notes. The email received in Outlook works fine but in Lotus Notes the table format is not in order. When I tried to forward what I recieved in Outlook to Lotus Notes then it works well. Upon checking the outlook body format in View Source after recieved and forwarded, I found out that Outlook changes the source from HTML to VML(i think) after I forwarded the message.

I am searching if there's a way to generate or convert HTML to VML using 'C#'.

Below link regarding Outlook VML for reference:

http://www.formatyourbrain.com/tips-for-creating-html-e-mail-templates-for-outlook/

Thanks!

2
Convert in what sense? HTML does not have recipients, subject, attachments, etc. Do you mean set the HTML body (use the MailItem.HTMLBody property in the Outlook Object Model)? Or create a MIME message?Dmitry Streblechenko

2 Answers

1
votes

The Outlook object model provides three different ways for working with item bodies:

  1. Body - a plain text, i.e. the clear-text body of the Outlook item.
  2. HTMLBody - an HTML markup.
  3. The Word Editor. Outlook uses Word as an email editor, so you can use it to format the email message. The WordEditor property of the Inspector class returns an instance of the Document class which represents the message body. Read more about all these ways in the Chapter 17: Working with Item Bodies in MSDN.

You can use the #2 and #3 options to set up the body. It looks like you need to copy the existing HTML markup and set the HTMLBody property of the mail item.

Due to the fact that Word is used as an email editor I'd recommend opening the HTML page in Word first. You can read about supported and unsupported HTML elements, attributes, and cascading style sheets properties in the following series of articles in MSDN:

0
votes

no need to convert, outlook will understand html. Here is an example: In your Winform or controller.

EmailMsg.Body = "<html><body><div style='border-style:solid;border-width:5px;border-radius: 10px; padding-left: 10px;margin: 20px; font-size: 18px;'> <p style='font-family: Vladimir Script;font-weight: bold; color: #f7d722;font-size: 48px;'> Blah Blah Blah</p><hr><div width=40%;> <p  style='font-size: 20px;'>Hello "
                +
                "</p><br>Someone made the following order. Make sure to check your paypal and confirm the payment<br><div style='width:30%; border-style:solid;border-width:1px;border-radius: 5px; padding: 10px;'>" + "The Word: " + word.Name + "<br> Number of letters: " + word.NumberOfLetter + "<br> Type of frame: " + word.TypeOfFrame + "<br> The total without tax and shipping: " + word.Amount + "<br> The images chosen: " + word.ImageOneID +
                "<div style='background-color: #6f7ef7; width: 180px; text-align: center;'><a style='color: white' href='https://www.paypal.com/'>GO TO PAYPAL</a></div><br><br>" +
                "</div></body></html>";