Genii Weblog


Civility in critiquing the ideas of others is no vice. Rudeness in defending your own ideas is no virtue.


Mon 8 Sep 2003, 04:24 PM
Rich Text 101 logo
While the subject of MIME/HTML may not seem quite in keeping with this series on rich text topics, the truth is that rich text is a loose term understood generally to mean the rich content in a field or on a form.  Under this definition, MIME/HTML is critical, as an increasing number of "rich text" fields are actually MIME fields with HTML content.  The main reason for this is SMTP and Internet mail, which comes into Notes as MIME and is transformed into rich text for rendering in the Notes client.

First, a short explanation of what MIME is, and how it relates to HTML.  MIME stands for Multipurpose Internet Mail Extensions.  There are many good explanations of MIME on the web, such as this one.  The gist is that MIME was developed as a flexible way to send messages across the internet in a way that could be transmitted as "text" instead of "binary".  It was also developed as a way to store rich content in a multiple parts, so that a simple e-mail reader could read the plain text of the message, while a more advanced e-mail reader could read the HTML (or other) to get a more rich experience.

In the Notes client, which is more advanced, we are able to read MIME messages with HTML rich content.  Graphics are stored as additional MIME parts, but are put together by the Notes client when reading the message.  Attachments may also be stored as additional MIME parts.  One thing which is not widely recognized is that the MIME is converted to rich text for rendering, even if the rich text is displayed by Domino to a web browser as HTML.  This will be discussed later, as it points out one of the major limitations of MIME content in Notes/Domino.

As mail from the Internet is very common, it is also very common to receive MIME messages.  If you have received e-mail from the Internet, you can take a look at the MIME format by selecting an Internet mail message from the Inbox, but not opening it, and looking at the document properties.  The Body field will often be split into several parts, and each will indicate that it is a MIME part.  If the Body field shows as rich text, and you have not opened the document to look at the properties, and you have not modified the document, it is likely that your incoming mail is being converted to rich text on the server.  This is generally not good, and can lead to some badly formatted messages and often broken image references.  In general, the Format preference for incoming mail in the Domino Directory Person document should be set to "Keep in Sender's format." if you are reading mail with the Notes 5 or Notes 6 client.

Yawn!  

Sorry, that part was just getting a bit long winded.  Sorry about that.  Let's cut to the more interesting bits.  How can I use MIME in Notes? What is it good for?  What are the downsides?  How long until rich text is replaced entirely by MIME?

How can I use MIME in Notes?
There are two basic ways.  You can send rich text in e-mails in MIME format by ensuring that your e-mail preference for sending to the internet is set to either HTML Only or HTML and plain text, with the latter being a better choice.  Mail messages will be converted automatically, and graphics and formatting and such will be preserved on outbound messages.

The second way allows you to use MIME even internally.  When you create a rich text field, you have a checkbox (on the second tab of the Field properties) which lets you set the storage type to Store contents as HTML and MIME.   Checking this tells Notes that when the document is saved, the rich text field should be converted to and saved as MIME.  The "HTML and MIME" simply means MIME which has at least an HTML part.

What is it good for?
Well, that depends on whether you are thinking inside or outside the box.  It allows interaction with the Java applet to be somewhat more predictable, since that is the format that the Java applet recognizes.  It similarly is accessible to other application which want to access the field through MIME parts from the web.  As various connections to Notes content through DB2 and portals and such are strengthened, this format is likely to become more important.

Thinking further outside the box, it allows you to convert rich text to HTML without running the Domino web server or HTTP task.  This HTML can then be extracted using the NotesMIMEEntity class.

What are the downsides?
Unfortunately, they are rather large.  The conversion to HTML is not a clean one.  CSS is not used, so HTML font sizes are rather crude approximations of the original font sizes (e.g., 13pt, 14pt, 15pt, 16pt and 17pt all translate to 14pt after going through the save and re-opening).  A return is added to the rich text each time the conversion i made, so after saving several times, there is a large empty space before the rich text begins.  Tabbed tables become regular tables.  Table lines converted from small think lines to "Ridge" format.  All cell borders use the value in the upper left hand corner on the left side, so a fancy table such as this:

SalespersonRegionSales '03
Jorge GonzalesSouthwest$115,305
Xavier ThomasNortheast$420,485

may be rendered instead as:

Salesperson Region Sales '03
Jorge Gonzales Southwest $115,305
Xavier Thomas Northeast $420,485

Then conversion of sections are is worse, as the section itself simply disappears, although the contents remain.

Why do you say MIME is always converted to rich text to display, and IBM says otherwise?
For some reason, many inside IBM, including developers, believe that MIME format is now supported natively in the Notes client.  This is clearly not true, as there are often messages about the conversion which trigger on opening the message, and as I have confirmed using an extension manager testing utility.  In R5, the same conversion is done when the document is rendered to the web, but it is possible (yet to be tested) that it has been fixed in ND6.  I'll update this document when I have further information.

How long until rich text is replaced entirely by MIME?
It isn't likely to happen anytime soon, thank goodness.  The higher priority at IBM right now is storing data in DB2, but it is easier to leave the basic storage as rich text and store that as a DB2 blob than to change the basic rich text format for now.  If handling of MIME gets more powerful, this might happen, but I personally think a conversion to XML is more likely, and also more desirable.

Copyright © 2003 Genii Software Ltd.

Tags: