Appending data to email body

I am looking for a way in lotus script to create text in a memo body, based on variable’s data which needs to be built in a “Do While” loop.With a connection to a DB2 database, I am comparing the key value of records in a Notes DB.

If I find the record does not exist in the Notes DB then I want to write the key value with some text to a variable that I can use in the body of a memo.

Example:

Employee Number 123 not found in Notes database

Employee Number 345 not found in Notes database

Employee Number 678 not found in Notes database

etc.

Any thoughts

Subject: Appending data to email body

This is from the Domino Designer Help

Dim doc As NotesDocument
Dim rtitem As Variant
'…set value of doc…
Set rtitem = doc.GetFirstItem( “Body” )
If ( rtitem.Type = RICHTEXT ) Then
Call rtitem.AppendText( “Add text to the rich text item” )
Call rtitem.AddNewLine( 1 )
Call rtitem.AppendText(“Add more text to rich text item”)
Call doc.Save( False, True )
End If

So you would just modify this to include your value in the string you are appending

Example

Call rtitem.AppendText( “Employee Number " & EmpNum & " not found in Notes database” )

Subject: RE: Appending data to email body

I looked all over the help and could not find this. I must have been looking in the wrong place

Thanks a heaping bunch.

Subject: RE: Appending data to email body

Carl,I’m getting an “Object variable not set” on the first “Call” line. I set the employeesNotfound Variant with the Body of the new Memo document.

What am I missing?

Dim memoDoc As NotesDocument

Dim employeesNotfound As Variant

Dim memoDoc As New NotesDocument (gLibCurrentDatabase)

Set employeesNotfound = memoDoc.GetFirstItem( “Body” )

**** This code is in the Do While Loop

Call employeesNotfound.AppendToTextList(“Employee Number: " + Trim (LCEMPNO.Text(0)) + " not found in Notes database”)

Call employeesNotfound.AddNewLine( 1 )

Subject: RE: Appending data to email body

Because it is a new document, there isnt a Body field to begin with. Use the CreateRichTextItem method of the NotesDocument class to create one then you can append text to it.

Subject: RE: Appending data to email body

Carl,I’m getting an “Object variable not set” on the first “Call” line. I set the employeesNotfound Variant with the Body of the new Memo document.

What am I missing?

Dim memoDoc As NotesDocument

Dim employeesNotfound As Variant

Dim memoDoc As New NotesDocument (gLibCurrentDatabase)

Set employeesNotfound = memoDoc.GetFirstItem( “Body” )

**** This code is in the Do While Loop

Call employeesNotfound.AppendToTextList(“Employee Number: " + Trim (LCEMPNO.Text(0)) + " not found in Notes database”)

Call employeesNotfound.AddNewLine( 1 )

Subject: RE: Appending data to email body

If this is a new document and not an existing document then you need something like as it doesn’t already exist. Be sure to look in help for other examples too.

Dim memoDoc As NotesDocument

Dim employeesNotfound As NotesRichTextItem

Dim memoDoc As New NotesDocument (gLibCurrentDatabase)

Set employeesNotfound = New NotesRichTextItem( memoDoc,“Body” )

Subject: RE: Appending data to email body

OK Carl we are almost there, however the string value that I need to append contains a numeric value that I covert to string.

key = LCEMPNO.Value(0)

Call rtEmployeesNotfound.AppendToTextList(“Employee Number: " + CStr ( key ) + " not found in Notes database”)…

So the AppendToTextList method does not like the CStr function. I get an error 4199: “Item %1 is not of type Text, special type not set” . Any idea why this would not work?

Subject: RE: Appending data to email body

Yes - you’re using AppendToTextList against a NotesRichtextItem, and that’s not allowed. (NotesRichTextItem inherits from NotesItem, so it does have the method, but it always throws an error once the underlying item is used as Rich Text.) You should be using AddNewline() and AppendText().

Subject: RE: Appending data to email body

Thanks Stan. That was it.