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
Subject: RE: Copy rtitem from backend to frontend
OK, that’s actually here:
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