vt100
vt100

Reputation: 1003

Get HTML from Outlook's message editor - ControlType.Document

I am trying to fetch HTML from the Outlook. Text format is set to HTML and that is what will be received by the exchange server after I send it.

I am able to get 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 any way to read HTML from the editor using .NET automation features?

Upvotes: 3

Views: 229

Answers (1)

Pranav Negandhi
Pranav Negandhi

Reputation: 1624

I think you're 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.

Upvotes: 2

Related Questions