WordEditor Modify HTMLBODY Formatting lost

K

krish

Hi All,

I am trying the following in Outlook 2003, configured to use MS Word
2003 as editor and the formatting for the any new text I type in the e-
mail is lost.

Here' what I am doing:
I am modifying the HMTLBody of the ActiveInspector. (A scenario to
recreate my problem is below)

Here's the problem:
After modifying the HTMLBody if I type in any text into the
ActiveInspector manually, the color of the font is not retained on the
new text.

A scenario to recreate this issue:
1. Compose a new e-mail (Word As Editor). Set the Font color for the e-
mail to Blue and Bold the font. Type in some test text into this e-
mail (This should appear to you as Blue and bolded).
2. Open outlook VBA and in the immediate window type in the following
and execute it:
ActiveInspector.CurrentItem.Htmlbody =
ActiveInspector.CurrentItem.Htmlbody

3. Now, go back into the e-mail that you are composing. You should
observe that any new text you type in has lost the color blue but it
retains the Bold formatting.

Any ideas on why this occurs, and how I may be able to get around this
problem?

Thank you,
Neil Goundar
 
K

Ken Slovak - [MVP - Outlook]

I have no idea why it occurs but you might be able to work around the
problem by getting the Word document object (WordEditor) and applying the
formatting using Word code on a selection range or the entire document's
range.
 
K

krish

Hi Ken,

Thank you for the reply. I really appreciate all the help that you are
providing,

The problem that I see in using in your approach is as follows:
1. If I am replying to a received e-mail, then the text that I type in
will appear Blue (default) in color when I type in anything into the
reply. And the original text will be black in color or what ever
formatting the sender sent in. Hence, I cannot apply the formatting to
the Selection or the range as I won't be able to identify which is
which.

Is there any other way to approach this?

What I am actually trying to do is read the text (formatted) text of
an existing e-mail and paste it into the new e-mail that I am
composing through an add-in. Initially I was modifying the HTMLBody,
but the above problem occurs if I try it with WordEditor.

I thought then to copy the first e-mail and paste it using the Word
Object model. This also, fails as How do I copy out the FORMATTED text
out of an existing e-mail in the explorer (without opening it) and
paste it into the open e-mail?

Any othe approaches I may take?

Thanks for all your advice to me so far.

Regards,
Neil Goundar.
 
K

Ken Slovak - [MVP - Outlook]

I can't think of any other approaches.

The problem with HTMLBody is that Word re-writes your HTML to its own
horrible HTML standards, which produces not only the ugliest HTML you'll
ever see but also it rearranges your tags and formatting to suit its own
formats. Try sending back and forth a few HTML items from WordMail and the
Outlook editor if you want to see really ugly HTML that ends up not looking
at all like the original. Not much you can do about that other than not
using WordMail (not even an option at all in Outlook 2007).

What you can do is get the text from Word as soon as the item is opened, at
that point you only have the original text plus the header separating the
original from what you type.

For an item in a folder or showing in the preview pane you can't use the
Word object model obviously, you'd have to get the text from HTMLBody from
the folder.Selection collection and instantiating the selected item as a
MailItem.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top