Copy rtitem from backend to frontend

Is it possible to copy a richtext item from a backend document (in this case a graphical element in a Profile document in the database) to the currently open uidoc (in this case a mail message)?

Subject: Copy rtitem from backend to frontend

I’m hoping you get a satisfactory answer myself.

I’ve done something very similar myself, appending an image to every newly opened mail message. We use this when we want to tell people about important events in the company (like when the office moved, and when we opened up a new one).

The problem with it is that you have to save the document, close and reopen it, which means everyone gets lots of drafts if they don’t end up sending the mails. We’re only a small company so no big deal, but you may want a more elegant solution which I hope somebody can give you. The following code is placed in the PostOpen event of the memo form (and reply and reply with history):

If source.IsNewDoc Then

	Call source.save

'ADD IMAGE FROM PROFILE DOCUMENT IN IMAGE DATABASE TO END OF BODY MIME ENTITY

	Dim s As New notessession

	Dim db As notesdatabase

	Set db = s.currentdatabase

	Dim idb As notesdatabase

	Set idb = New notesdatabase(db.server, "IT/Im.nsf")

	Dim profdoc As notesdocument

	Set profdoc = idb.GetProfileDocument("Office Move")

	Dim item As notesrichtextitem

	Set item = profdoc.GetFirstItem("OfficeMove")

	

	Dim mdoc As notesdocument

	Set mdoc = source.document

	Call source.close

	

	Dim bodyitem As notesrichtextitem

	Set bodyitem = mdoc.getfirstItem("Body")

	Call bodyitem.AddNewline(1)

'append to the body field

	Call bodyitem.AppendRTItem(item)

	Call bodyitem.Update

	Call mdoc.Save(True, True)

	

	Dim w As New notesuiworkspace

	Call w.EditDocument(True, mdoc)

End If

Subject: RE: Copy rtitem from backend to frontend

See Andre Guirard’sTip: How to update rich text in a document that’s open and redisplay it without saving

at

http://www-10.lotus.com/ldd/nd6forum.nsf/DateAllThreadedweb/066f93582af6f0d385257259003feb44?OpenDocument

Subject: RE: Copy rtitem from backend to frontend

OK, that’s actually here:

http://www-10.lotus.com/ldd/nd6forum.nsf/55c38d716d632d9b8525689b005ba1c0/dd507a5be7cc2e4285256eec005f56ef?OpenDocument

That’s not far off what I’ve done, still involves closing and reopening the doc, and in the situation I posted I was using postopen (although I guess I could check for the attachment existing).

Andre’s post is a good one though (as always)

Dan