views:

2144

answers:

4

I'm working on a data migration task, where I have to export a somewhat large Lotus Notes application into a blogging platform. My first task was to export the articles from Lotus Notes into CSV files.

I created a Agent in LotusScript to export the data into CSV files. I use a modified version of this IBM DeveloperWorks forum post. And it basically does the job. But the contents of the Rich Text field is stripped of any formatting. And this is not what I want, I want the Rich Text field rendered as HTML.

The documentation for the GetItemValue method explicitly sates that the text is rendered into plain text. So I began to research for something that would retrieve the HTML. I found the NotesMIMEEntity class and some sample code in the IBM article How To Access HTML in a Rich Text Field Using LotusScript.

But for the technique described in the above article to work, the Rich Text field need to have the property "Store Contents as HTML and MIME". And this is not the case with my Lotus Notes database. I tried to set the property on the fields in question, but it didn't do the trick.

Is it possible to use the NotesMIMEEntity and set the "Store Contents as HTML and MIME" property after the content has been added, to export the field rendered as HTML?

Or what are my options for exporting the Notes database Rich Text fields as HTML?

Bonus information: I'm using IBM Lotus Domino Designer version 8.5

A: 

You can use the NotesDXLExporter class to export the Rich Text and use an XSLT to transform the output to what you need.

Carlos
Great info, I will look into that!
Emil Rasmussen
I tried to use the NotesDXLExporter, but it only renders the Rich Text field as some strange XML version of the Rich Text. It would be cumbersome to transform it to HTML. Thanks for the suggestion though!
Emil Rasmussen
+1  A: 

I'd suggest looking at Midas' Rich Text LSX (http://www.geniisoft.com/showcase.nsf/MidasLSX)

I haven't used the personally, but I remember them from years ago being the best option for working with Rich Text. I'd bet it saves you a lot of headaches.

As for the NotesMIMEEntity class, I don't believe there is a way to convert RichText to MIME, only MIME to RichText (or retain the MIME within the document for emailing purposes).

Ken Pespisa
Looks cool, I will try it out. Thanks.
Emil Rasmussen
+2  A: 

If you upgrade to Notes Domino 8.5.1 then you can use the new ConvertToMIME method of the NotesDocument class. See the docs. This should do what you want.

Alternativly the easiest way to get the Domino server to render the RichText will be to actually retrieve it via a url call. Set up a simple form that just has the RichText field and then use your favourite HTTP api to pull in the page. It should then be pretty straight forward to pull out the body.

kerrr
I just got my evaluation license for Midas' Rich Text LSX. So I will try that. Thanks for the tip about upgrading 8.5.1. I will try that if LSX doesn't do it's magic.
Emil Rasmussen
+1  A: 

I know you mentioned using LotusScript, but if you don't mind writing a small Java agent (in the Notes client), this can be done fairly easily - and there is no need to modify the existing form design.

The basic idea is to have your Java code open a particular document through a localhost http request (which is simple in Java) and to have your code capture that html output and save it back to that document. You basically allow the Domino rendering engine to do the heavy lifting.

You would want do this:

  1. Create a form which contains only the rich-text field you want to convert, and with Content Type of HTML
  2. Create a view with a selection formula for all of the documents you want to convert, and with a form formula which computes to the new form
  3. Create the Java agent which just walks your view, and for each document gets its docid, opens a URL in the form http://SERVER/your%5Fdatabase%5Fpath.nsf/NEW%5FVIEW/docid?openDocument, grabs the http response and saves it.

I put up some sample code in a similar SO post here:

http://stackoverflow.com/questions/1356143/how-to-convert-text-and-rich-text-fields-in-a-document-to-html-using-lotusscript/1357566#1357566

Ed Schembor
Great response! Always nice with code examples :-) I will try Midas' Rich Text LSX before turn to Java (just got my evaluation licence).
Emil Rasmussen