Extract and replace the email's body (VSTO, Outlook 2007)

T

thomas.schager

Hi,

for a small project I try to analyse (amongst others) the text section
of an email using VSTO 2005 (C#) in Outlook 2007.

First, I need to seperate the text component of the mail body. With
the MailItem.BodyFormat property, I can differentiate in olFormatHTML,
olFormatPlain, olFormatRichText and olFormatUnspecified. How can I get
a string containing the email's text independent of the BodyFormat?

Second, I need to edit these different text components. For
olFormatPlain, this is not quite difficult. But how can I efficiently
edit HTML or RichText?


Thanks in advance,
Thomas
 
K

Ken Slovak - [MVP - Outlook]

If you want the text you can use item.Body. Using item.HTMLBody will return
the actual HTML code if the message is in HTML format. Rich text can be
gotten from Body or if you want the RTF coding you can get it from HTMLBody,
where it's wrapped in HTML tags. To get the actual pure RTF you would need
to use the PropertyAccessor to access property PR_RTF_COMPRESSED
(0x10090102), although that might be truncated if the size exceeds about 4K,
since PropertyAccessor doesn't fall back to an IStream if the size of a
property exceeds what can be retrieved using a MAPI property call.
 

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