I am putting together an application that’s used exclusively via the web.
Part of the application involves adding reference items that may be selected to be put into an email and sent to recipients (essentially a summary email listing all the reference items and their associated attachments).
The issue I have is making sure the attachments are in a specified rich text field so that they are included in the email (the email body is derived by using AppendRTItem).
I have come across 3 ways which I think I can use to do this in version 6:
-
User presses the submit button twice in which case the attachments automatically populate the RTF on the form. Not really acceptible. I did try using two @Command([FileSave]), which did save the document twice but didn’t have the desired affect of putting the attachment in the RTF.
-
Using extractfile method (I’ve found a number of examples of this including the technote) but I would rather not use the underlying file system.
-
Using rendertoRTItem method to copy the entire document to a temporary document then using the NotesRichTextNavigator to strip out everything aside from the attachments and then append these to the original document before saving.
I have been trying method 3 (please see code snippet listing below) and I must be missing something in understanding how everything fits together.
The temporary document is created as intended but the attachment does not form any of the rendered items (I had thought that as a document attachment it would be part of the entire document rendered). I am about to try saving the document context to see if that makes a difference but it then becomes a very convoluted way of doing something, which I thought should be relatively straightforward given the new methods in R6.
Set db = session.CurrentDatabase
Set docContext = session.DocumentContext
'create a temporary document in which to render the docContext as a rich text item
Set docTemp = New NotesDocument( db )
'create a rich text item in the temporary document
Set rtItem = New NotesRichTextItem( docTemp, “Body” )
success = docContext.RenderToRTItem( rtItem )
If success Then
Call docTemp.Save(True,False)
End If
Thanks for any insight.