Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 557
vt100 Avatar asked Sep 03 '26 17:09

vt100


1 Answers

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.

like image 77
Pranav Negandhi Avatar answered Sep 05 '26 07:09

Pranav Negandhi