Domino Code Fragment

Code Name*
Moving file attachments added via the web to a RT field using $$QuerySaveAgent
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.18.221.53.5
Description*
Moving file attachments added via the web to a RT field using $$QuerySaveAgent
Type*
LotusScript
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
Files/Graphics attachments (if applicable): Code:

$$QuerySaveAgent code to move the attachments added via the web to a rich text field in the document:

Dim session As New NotesSession
Dim doc As NotesDocument
Set doc = session.DocumentContext
Dim db As NotesDatabase
Set db = session.CurrentDatabase
'Move the V2 file attachment to the rich text field
Set rtitem = New NotesRichTextItem ( doc, "AttachmentFiles" )
Set FileList = doc.GetFirstItem("$File")
If Not FileList Is Nothing Then
Forall item In Filelist.values
Set object = doc.GetAttachment( item)
If object.Type = EMBED_ATTACHMENT Then
datadir$ = session.GetEnvironmentString("Directory", True)
FilePath$ = datadir$ & "\" & item
Call object.ExtractFile(FilePath$)
Call object.remove
Call rtitem.embedObject(EMBED_ATTACHMENT,"",FilePath$,"")
End If
End Forall
' Finally, delete the file from the file system
On Error Resume Next
Kill FilePath$
End If