[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Agent to Import HTML file into a rich text field.

Posted on 2007-07-31
6
Medium Priority
?
772 Views
Last Modified: 2013-12-18
I use the Excell Publish feature to create an HTML file, and I want to use an agent to the import files into rich text field in a document in a Notes database.   I use the term 'import' because I know I can do File Import as a user, and I can create a button for the user to press which does the 'import' process which is available as a method under notesUIDocument.   But, I can't find a way to do the import as an agent which could be run in batch to update a group of documents with the appropriate HTML files.  The database is published to the web and these documents are normally viewed by a browser.
I have found an approximation by using Stream and bringing the text into the field.  With passthru HTML turned on the field is correct when viewed with a browser.  But the HTML code is seen when the document is viewed with the Notes client.  I would rather have the action of 'import'.
0
Comment
Question by:Charlie Neumann
6 Comments
 
LVL 22

Accepted Solution

by:
Bill-Hanson earned 1500 total points
ID: 19605111
There is no backend support for the ui "import" feature.  Like you, I've had limited success using pass-thru html, so I decided to try my hand at loading HTML into RichText fields as MIME.  It has been working good for me so far, but I've only been working with simple text formatting and images.  If you're interested, take a look at the NotesMimeXXX classes.
0
 

Author Comment

by:Charlie Neumann
ID: 19605584
I looked at MIME but I'm working with an existing form design where the field name is 'WebPageContent'.  It appears that only choice with MIME would be to create a new item in the document.  I would have to delete the existing rich text field and recreate it as a MIME entity.  I wanted to avoid that for other reasons.  We'll see if MIME is the only way to go.

For reference;   This is the basics of the code which I use for what is approximately working now;

LotusScript Code:
Option Public
Dim fileNum As Integer
Dim fileName As String
Dim inrec As Variant
Dim doc As NotesDocument
Dim rtitem As NotesRichTextItem
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim inStream As NotesStream
Dim item As NotesItem
Dim richStyle As NotesRichTextStyle
' Developer note:
'  " WebPageContent" is an existing field in the form.
'  The hard coded fileName$ should be replaced by a string value from the form.
Sub Initialize
      Dim session As New NotesSession
      Set db = session.CurrentDatabase
      Set collection = db.UnprocessedDocuments
      Set doc = collection.GetFirstDocument()
      While Not(doc Is Nothing)
            fileName$ = "C:\Temp\stockspecial6100.htm"
            Set inStream = session.CreateStream
            If Not inStream.Open(fileName, "ASCII") Then
                  Messagebox fileName,, "Open failed"
                  Exit Sub
            End If
            If inStream.Bytes = 0 Then
                  Messagebox fileName,, "File has no content"
                  Exit Sub
            End If
            Set item = Doc.ReplaceItemValue("WebPageContent","")
            Set rtitem = doc.GetFirstItem( "WebPageContent" )
            Set richStyle = session.CreateRichTextStyle
            richStyle.PassThruHTML = True
            Call rtitem.AppendStyle(richStyle)
            Buffer$ = inStream.ReadText()
            Call rtitem.AppendText(Buffer$)
            Call inStream.Close
            Call doc.Save( False, True )
            Set doc = collection.GetNextDocument(doc)
      Wend
End Sub
      
0
 
LVL 46

Expert Comment

by:Sjef Bosman
ID: 19607411
The essential line in the code is
            richStyle.PassThruHTML = True

Almost the same code would apply for creating just a new paragraph, with the correct style set, to add your HTML.
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

Author Comment

by:Charlie Neumann
ID: 19607763
The code example is less than desired because users viewing the document in Notes shows HTML code, not what the browser viewer sees.
0
 

Author Comment

by:Charlie Neumann
ID: 19613623
I'm pleased to learn that I had found the only viable solution.  Thanks for the response.  Apparently it was as difficult as I thought.
0
 
LVL 31

Expert Comment

by:qwaletee
ID: 19616565
There is another solution, but it is quite complicated.  It is possible to transform XHTML into DXL and import it.

An additional way would be to use the Midas rich text libraries.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

IBM Notes offer Encryption feature using which the user can secure its NSF emails or entire database easily. In this section we will discuss about the process to Encrypt Incoming and Outgoing Mails in depth.
This article covers general Notes 8.5 troubleshooting information including recreating the Notes\Data folder.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question