rtLib — Notes Rich Text Management Library Documentation of rtLib — Notes Rich Text Management Library Download rtLib — Notes Rich Text Management Library FAQ of rtLib — Notes Rich Text Management Library Purchase rtLib — Notes Rich Text Management Library Feedback about rtLib — Notes Rich Text Management Library

Handling of Rich Text objects

Simple example of creation of section and adding a rich text

Start search Mail feedback Back to Description

In order to create a rich text item the objects must be first added to rtContainer object. The containers and objects are quite independent and an object as a rule may be simultaneously added to several containers.

Note however that using it in this way may not always work. The recommended way is to associate the object with only one container. In order to associate it with other container first use rtSomeObject.remove() to disassociate with parent container then rtTargetObject.add rtSomeObject to attach it in another place.

The sequence of creation of a simple rich text item:

Dim ctx as new rtContainer ' container exists independently of Notes objects until AppendItemValue or ReplaceItemValue method is executed
Dim font as rtFontStyle ' let's separately define the look of the text
Dim para as rTextParagraph ' a container for any objects
Dim sect as rtSection

Set ctx = new rtContainer
' let's set a font to be used as Title
Set font = new rtFontStyle(0) ' the styles require an argument, though not used in current version; any numeric value will be disregarded
Font.Typeface = "Arial"
Font.FontColor = NOTES_COLOR_RED ' this property allows to define a limited set of basic colors; slighly different approach using rtColor class allows to define any color in RGB space.

' create a Text paragraph
Set para = ctx.appendText ("Dump of Mails") ' this results in creation of a new paragraph (if one does not exist) and a rTextRun
para.Current.Style.Font = Font ' set font of last added text element - rTextRun

Set sect = new rtSection
.Title = "1st mail" ' set section title
ctx.add sect
' as the object are real objects we may manipulate them also after they are added to the container
ctx.appendText "!"
ctx.addnewLine 1 ' we create a new paragraph
' and now a slight volte-face; let's assume, that we have obtained our mail document as docMail
sect.Content.getRichTextItem docMail, "Body"

Any objects that may contain other objects like sections has a Content property, that returns rtContainer object. The Content may be used to retrieve (and write rich text item) on any level of containment.

As a result of this code we have a rich text container containing title and section with the content of mail document "Body" item.

Now we can preserve the result:

Sect.isCollapsed = true ' make section collapsed
' let's assume that we need to store the result in doc
ctx.ReplaceItemValue doc, "Body"
doc.save true, true

Done - the body item of mail document is saved in a collapsed section.

See more detailed description in reference section concerning the specific object classes.