My agent loops thru some “products”, each of which has “posts”. It generates an email containing the data. It formats a rich-text field using a NotesRichTextItem (named “Body”) and some NotesRichtextStyle objects. The only thing that is wrong is that the formatting of the Body field does not obey the styles used.
I am testing the agent on my client, Designer 6.5 from September 26, 2003.
'Loop over Products
Forall prod In aOneUsersProducts
If ProductHasNewDocs( prod ) Then
aDocs = DocDataByProduct( prod )
Call rtitem.AppendStyle( rtsHel12Red )
Call rtitem.AppendText( "New Posts for Product: " & prod & Chr(13) & Chr(13) )
Call rtitem.AppendStyle( rtsHel10Black )
' Loop over the posts
For ix = 1 To Ubound( aDocs, 2 )
Call rtitem.AppendText( "Subject: " & aDocs( conSUBJECT, ix) & Chr(13) )
Call rtitem.AppendText( "Posted by: " & aDocs( conAUTHOR, ix) & Chr(13) & Chr(13) )
Next
End If
End Forall
Clearly the “New Posts for Product” lines should display in 12-point Red Helvetica, while the “Subject” and “Posted By” lines should be in 10-point Black Helvetica .
Instead, the first “New Posts for Product” line is correctly formatted in 12-point Red Helvetica. All the rest of the lines are in 10-point Black Helvetica .
I have tried the suggestions I found in this forum including:
– add a space with .AppendText( " " ) and then call .AppendStyle() again.
– Reset the NotesRichtextStyle objects to Nothing and recreate them before the .AppendStyle() .
These ideas did not work. Also, I tried creating a new (temp) RichTextItem, then appending the style and the text to the temp RTI, then appending that entire item to the Body RTI. That doesn’t work either.
Any other ideas?
The NotesRichtextStyle object variables are global and are set with this subroutine:
Sub SetupStyles
Set rtsHel14Red = Nothing
Set rtsHel14Red = S.CreateRichTextStyle
With rtsHel14Red
.NotesFont = FONT_HELV
.FontSize = 14
.NotesColor = COLOR_RED
.Bold = True
.Underline = False
End With
Set rtsHel12Red = Nothing
Set rtsHel12Red = S.CreateRichTextStyle
With rtsHel14Red
.NotesFont = FONT_HELV
.FontSize = 12
.NotesColor = COLOR_RED
.Bold = True
.Underline = False
End With
Set rtsHel10Black = Nothing
Set rtsHel10Black = S.CreateRichTextStyle
With rtsHel10Black
.NotesFont = FONT_HELV
.FontSize = 10
.NotesColor = COLOR_BLACK
.Bold = True
.Underline = True
End With
End Sub
Calling this subroutine before each AppendStyle() does not help.