Move attachment from selected multiple documents in view to a new form

Hi,

I’m new to lotusscript and just finding my way around.

I’m trying to performing the following sequence.

  1. Detach terms.pdf from selected files.

  2. Detach remaing invoices to local hard drive.

  3. Attach all invoices within that directory to a new form for sending out.

I can remove the terms and conditions and save the invoices to the local drive drive but i’m struggling to work out how to attach all the local invoices back into a new form.

Any help appreciated. Code done so far detailed below :

Sub Initialize

Dim s As New NotesSession

Dim db As NotesDatabase

Dim coll As NotesDocumentCollection

Dim doc As NotesDocument

Dim eo As NotesEmbeddedObject

Dim RTITEM As NOTESrICHtEXTiTEM

Dim Counter As Integer

Set db=s.CurrentDatabase

Set coll=db.UnprocessedDocuments

For a=1 To coll.count

Set doc=coll.GetNthDocument(a)

Set rtitem = doc.GetFirstItem(“Body”)

Forall o In rtitem.EmbeddedObjects

If o.name = “Terms.pdf” Then

Call o.remove

End If

Call doc.Save( True, True )

End Forall

Next

Counter = 1

For a=1 To coll.count

Set doc=coll.GetNthDocument(a)

Set rtitem = doc.GetFirstItem(“Body”)

Counter = Counter + 1

Forall o In rtitem.EmbeddedObjects

oname="c:\Extracted" + o.name

Call o.ExtractFile( oname )

'Messagebox o.name

End Forall

Next

Dim workspace As New NotesUIWorkspace

Call workspace.ComposeDocument( “”, “”, “ForwardEmail2” )

Dim filename As String

Dim body As NotesRichTextItem

Dim object As NotesEmbeddedObject

Set db = s.CurrentDatabase

Set doc = db.CreateDocument

Set body = doc.CreateRichTextItem(“Body”)

doc.Form = “formularz”

filename$ = Dir$(“c:\Extracted*.*”)

Do While filename$ <> “”

Set object = body.EmbedObject(EMBED_ATTACHMENT, “”, "c:\Extracted" & filename$)

Call doc.Save(True, False)

’ Kill "c:\Extracted" & filename$

filename$ = Dir$(“c:\Extracted*.*”)

Messagebox filename$

Loop

End Sub

Subject: Move attachment from selected multiple documents in view to a new form

Are you getting any error?

I don’t think this is the problem but the line filename$ = Dir$(“c:\Extracted*.*”) within the loop should be filename$ = Dir$()