Replace attachments with text in NotesRichtTextItem

I want to replace attachments in a NotesRichTextItem with the filenames of the attachments. The replacements should be on the same position in text where the attachments are, not on the end of the text. A analogous functionality like the action “Forward without attachments” in the mail application.

Subject: look at the mail file

dig through the design and see how they do it.

Subject: I do not need a compose function

I do not want to compose a neu document like the @Command [ComposeWithReference] do. I need a Lotus Script solution.I have tried NotesRichTextNavigator and NotesRichTextRange. They can’t iterate over words, or characters in general, so I cannot fix the position of the attachments in my text.

Subject: this works for me

Sub Initialize

Dim ns As New NotesSession

Dim db As NotesDatabase

Dim dc As NotesDocumentCollection

Dim doc As NotesDocument

Dim body As NotesRichTextItem

Dim rtnav As NotesRichTextNavigator

Set db = ns.CurrentDatabase

Set dc = db.UnprocessedDocuments

If dc.Count = 0 Then

	Messagebox "No document selected",, "No doc"

	Exit Sub

End If

Set doc = dc.GetFirstDocument

count = Evaluate(|@Attachments|, doc ) 

If count(0) > 0 Then

	Set body = doc.GetFirstItem("Body")

	Set rtnav = body.CreateNavigator

	Forall o In body.EmbeddedObjects

		If rtnav.FindFirstElement(RTELEM_TYPE_FILEATTACHMENT) Then

			Call body.BeginInsert( rtnav, True )

			txt$ = "detached file to c:\temp\" & o.Source

			Call body.AppendText( txt$ )

			Call body.EndInsert

			Call o.ExtractFile( "c:\temp\" & o.Source )

			Call o.Remove

			Call doc.Save( False, True )

		End If

	End Forall

Else

	Messagebox "No attachment in Body",, "No file"

End If

End Sub

Subject: Thanks!

That’s exactly what I was looking for.

Thank you!