Get HTML from Outlook Message Editor - ControlType.Document

I am trying to extract HTML from Outlook. The text format is set to HTML and this is what will be received by the exchange server after it has been sent.

I can get the text using:

if (e.Current.ControlType == ControlType.Document && e.Current.Name == subject+" - Message")
{
       TextPattern v = (TextPattern)e.GetCurrentPattern(TextPattern.Pattern);
       System.Console.WriteLine("DOC:"+ v.DocumentRange.GetText(-1));
}

      

Is there a way to read HTML from an editor using .NET automation features?

+3


source to share


1 answer


I think you are working with the wrong class. I extracted the following snippet from an example on the Microsoft support website. HTMLBody is a getter / setter (although it is used as a setter in this example).

Outlook.MailItemClass mItem = (Outlook.MailItemClass)doc.MailEnvelope.Item;
mItem.Subject = strSubject;
mItem.BodyFormat = Outlook.OlBodyFormat.olFormatHTML;
mItem.HTMLBody = GetString(strBody);

      



The full article is available here.

+2


source







All Articles