Re: RTF Conversion Error

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



What do you see for PR_BODY and PR_RTF_COMPRESSED in OutlookSpy or MFCMAPI?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"BenM" <nospam@xxxxxxxxxx> wrote in message
news:%23yNVSBZhIHA.4376@xxxxxxxxxxxxxxxxxxxxxxx
Hi Dmitry, and thanks for having a look.

Yes. To the best of my knowledge, PR_BODY is set correctly. That is, it is
set to the plain text version of the message, and it appears as such when
querying the message content later.

The general sequence of events is
1) Set PR_BODY to the text message.
2) Set PR_MSG_EDITOR_FORMAT to 2
3) Set PR_BODY_HTML to the html encoded version of the message, which
consists of the html signature, with the html version of the text message
inserted, surrounded by <p> and </p>, after the opening <body..> tag.
4) Set PR_RTF_COMPRESSED to the rtf version of the message, which is
effectively PR_BODY_HTML, converted to RTF using the technique described
earlier. Also note that RTF is written using a stream and
WrapCompressedRTFStream as described in the documentation.

The process above seems to work well apart from this oddball \par <P>
appearing in the translated html.

Regards,

Ben


"Dmitry Streblechenko" <dmitry@xxxxxxxxxxx> wrote in message
news:OOvtwNYhIHA.3940@xxxxxxxxxxxxxxxxxxxxxxx
Are you sure PR_BODY is correctly set?

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool

"BenM" <nospam@xxxxxxxxxx> wrote in message
news:eNF$Q0XhIHA.6136@xxxxxxxxxxxxxxxxxxxxxxx
Hi all,

I have come across a problem with an html message sent by my program to
an Outlook 2003 client. The client displays the message correctly, but
when the message is received, the small 'preview' tooltip (screenshot
attached) displays part of the raw message code.

The relevant section of the signature's html (which we are reading from
C:\Documents and Settings\UserName\Application
Data\Microsoft\signatures) is in the <head></head> section and looks
like:

<!--[if !mso]>
<style>
v\:* {behavior:url(#default#VML);}
o\:* {behavior:url(#default#VML);}

As Outlook seems to use PR_RTF_COMPRESSED to generate PR_HTML rather
than use the html version I have supplied, my code (also attached)
converts the html message, including the signature, to RTF, and this
code block is converted to

{\\*\\htmltag0 <!--[if !mso]>}
{\\*\\htmltag0 \\par }
{\\*\\htmltag0 <style>}
{\\*\\htmltag0 \\par }v\\\\:* \\{behavior:url(#default#VML);\\}
{\\*\\htmltag0 \\par }o\\\\:* \\{behavior:url(#default#VML);\\}

But, when Outlook then converts this RTF to HTML it adds what appears to
be a spurious \par <P> in the middle.

{\*\htmltag241 <!--[if !mso]>\par <style>\par \par <P>v\\:*
\{behavior:url(#default#VML);\}\par o\\:*
\{behavior:url(#default#VML);\}\par (.)

If, however, I generate the same message within Outlook itself, the same
rtf line appears fine:

{\*\htmltag241 <!--[if !mso]>\par <style>\par v\\:*
\{behavior:url(#default#VML);\}\par o\\:*
\{behavior:url(#default#VML);\}\par (.)

The assumption being that the preview tooltip is encountering the <P>
and displaying the "message" that follows. The question is: How can we
get rid of the <P>? Is there a way adequately generate RTF from an HTML
message so that this sort of thing does not happen?

The HTML to RTF routine is attached and is derived from various examples
I found on the internet that attempted to achieve this same goal.

Any advice would be much appreciated.

Best Regards,

Ben








.



Relevant Pages

  • Re: Exchange 2003 communication differences
    ... you're correct that Entourage and Outlook connect to Exchange ... messages in HTML, RTF and Plain text. ... HTML, however, old mail stores still have RTF as the default. ...
    (microsoft.public.mac.office.entourage)
  • Re: Attachment sent becomes winmail.dat?
    ... nothing to do with Outlook, and as you can see for yourself, does not have RTF format, Only plain text and HTML. ... I did not know that Entourage lacked RTF. ... it can handle HTML but not consistently. ... Many other people here use plain text emailers on UNIX boxes or similar packages. ...
    (microsoft.public.mac.office.entourage)
  • Re: Windows Mail Not receiving My Attachments
    ... RTF is best used within an organization where all users use OL and in an Exchange Server environment. ... Outlook also has other options that need to be configured properly if these attachments are pictures to be displayed in OL. ... I can verify that OL03 and OL07 both function in Vista for Html and Plain Text sending/receiving non restricted attachments when RTF is not manually configured to be the composition format. ...
    (microsoft.public.windows.vista.mail)
  • =?ISO-8859-15?Q?Re:_Anh=E4nge_in_RTF-Mails_werden_beim_Empf=E4nger_nicht_a?= =?ISO-8
    ... Ich habe zwar in der Vergangenheit nicht allzu viel mit Outlook gemacht, aber die Umwandlung von dort erstellten HTML-mails in "plain-text" und Verlust der Anlagen ist mir nie begegnet. ... Ich habe vorhin auf meinem alten Notebook, auf dem OL 2003 liegt, mehrere Testmails erstellt, sowohl mit RTF, als auch mit HTML und jeweils mit Anlagen. ... Auszug aus dem Sourcecode einer unter OL 2003 erstellten mail mit RTF ...
    (microsoft.public.de.outlook)
  • Re: PR_BODY_HTML to PR_RTF_COMPRESSED to PR_BODY
    ... > You can load the RTF into a hiden RTF control, then stream it out as plain ... > In case of HTML, you can load it into an instance of IHTMLDocument2 object ... > OutlookSpy - Outlook, CDO ... >>> the right RTF tags for each HTML tag the way Outlook does it. ...
    (microsoft.public.win32.programmer.messaging)