Link to home
Start Free TrialLog in
Avatar of KTTKTT
KTTKTTFlag for United States of America

asked on

Lotus Notes Agent creates a memo and appends richtext to richtext to plain text for memo

1.  User opens a new request and adds text to a richtext description field and submits request.
2.  Mail routing occurs with the description field in the body of the memo.
3.  On doc submission, an agent runs to create memo and append richtext.
4.  The first line is predetermined plain text.
5.  The next lines include the richtext description field entered by user.
6.  The last line appends more predetermined plain text to that richtext.

Problem is formatting when user adds bullets or numbering.  The memo displays the 1st and last text lines ok, but places the richtext bulleted text left of the screen as follows:

          line 1: Description plain text:

          This is the richtext user adds to description field with bullests.

            aaaaaaaaaa
            bbbbbbbbbb
            cccccccccccccc

1.  kljasf;jas;d - bullets or numbering formats left of screen.
2.  adl;jdflasjf;

              last line: Please click link to review your request:


........
Dim rtitem As NotesRichTextItem
	Dim item As NotesItem
'	Dim rtitem2 As NotesItem
	Dim rtitem2 As NotesRichTextItem   

....
...

                Set richstyle = session.CreateRichTextStyle
		Set rtitem = New NotesRichTextItem( newDoc , "Body" )
		
		richstyle.NotesColor = COLOR_DARK_BLUE
		richStyle.FontSize = 10
		richStyle.Bold = True
		Call rtitem.AppendStyle(richstyle)
			
		Call rtitem.AddNewLine( 1 )
		richstyle.NotesColor = COLOR_DARK_MAGENTA
		richStyle.Italic = True
		Call rtitem.AppendStyle(richstyle)
		Call rtitem.AppendText(" line 1: Description plain text")
		
		Call rtitem.AddNewLine( 2 )
'		Call rtitem.AddTab( 1 )
		richstyle.NotesColor = COLOR_BLACK
		richStyle.FontSize = 9
		richStyle.Bold = True
		richStyle.Italic = False
		Call rtitem.AppendStyle(richstyle)
					
		Set rtitem2 = doc.getfirstitem("Description") 
		Call rtitem.AppendRTItem(rtitem2)
		
		richStyle.Italic = False
		
		Call rtitem.AddNewLine(2)
		richstyle.NotesColor = COLOR_DARK_BLUE
		richStyle.FontSize = 10
		richStyle.Bold = True
		Call rtitem.AppendStyle(richstyle)
		
					
		Call rtitem.AddNewLine(2)
		Call rtitem.AppendText("last line: Please click link to review your request:")
		Call rtitem.AppendDocLink( docnew , db.Title)   
		newDoc.Subject = ("Action required" )
		
		Call rtitem.AddNewLine(1)
		newDoc.SendTo = doc.dev
			newDoc.CopyTo = doc.plan
				newDoc.Send( False )

Open in new window

Avatar of mbonaci
mbonaci
Flag of Croatia image

25 pts?!?

Look at RichTextParagraphStyle class.
Properties LeftMargin and RightMargin.
Ignore the first line of my post.
This is how it works:
Dim s As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim rt As NotesRichTextItem
Dim rts As NotesrichTextParagraphStyle

Set db = s.Currentdatabase
Set doc = New NotesDocument(db)
Call doc.AppendItemValue("From", s.Username)
Call doc.AppendItemValue("Subject", "Test paragraph style")

Set rts = s.CreateRichTextParagraphStyle
Set rt = New NotesRichTextItem(doc, "Body")
rts.LeftMargin = 2 * 567    '2cm

Call rt.AppendParagraphStyle(rts)
Call rt.AppendText("New indent starts here")
Call rt.AddNewLine(1)
Call rt.AppendText ("what happens here")

Call doc.Save(True, False)

Open in new window

Avatar of KTTKTT

ASKER

mbonaci,

Thanks for the example!

after the subject line, I need to append text to the Body.
2nd need to append richtext Description field to that,
3rd need to append text to it.

trying to get the order right.  Do I use the rts.leftmargin setting after the 1st line of text before I append the richtext description field>   At the end of say line 19 after the text, do i do something like this:

Set rt = New NotesRichTextItem(doc, "Description")
Call rt.AppendParagraphStyle(rts)

then go back to appending text with Call rt.AppendText("this is text")

thx
ASKER CERTIFIED SOLUTION
Avatar of mbonaci
mbonaci
Flag of Croatia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial