How to export Rich Text fields as HTML from Notes with LotusScript?

40,159

Solution 1

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).

Solution 2

There is this fairly unknown command that does exactly what you want: retrieve the URL using the command OpenField.

Example that converts only the Body-field:

http://SERVER/your%5Fdatabase%5Fpath.nsf/NEW%5FVIEW/docid/Body?OpenField

Solution 3

Here is how I did it, using the OpenField command, see D.Bugger's post above

Function GetHtmlFromField(doc As NotesDocument, fieldname As String) As String
    Dim obj
    Set obj = CreateObject("Microsoft.XMLHTTP")
    obj.open "GET", "http://www.mydomain.dk/database.nsf/0/" + doc.Universalid + "/" + fieldname + "?openfield&charset=utf-8", False, "", ""
    obj.send("")

    Dim html As String
    html = Trim$(obj.responseText)

    GetHtmlFromField = html
End Function

Solution 4

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.

Solution 5

Keep it simple.

Change the BODY field to Store contents as HTML and MIME

Open the doc in editmode. Save. Close.

You can now use the NotesMIMEEntity to get what you need from script.

Share:
40,159
Emil Rasmussen
Author by

Emil Rasmussen

Updated on July 09, 2022

Comments

  • Emil Rasmussen
    Emil Rasmussen almost 2 years

    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 states 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