There is a document with multiple attachments & i have to create document for eact attachment

Hi All

There is a document with multiple attachments & i have to create document for eact attachment.

Im creating multiple documents but all documents creating with all attachments.

Here is the code

================

Dim session As New NotesSession

Dim db,db1 As NotesDatabase

Dim doc As NotesDocument

Dim doc1 As NotesDocument

Dim itemA As NotesItem

Dim rtitem As Variant

Dim view As NotesView



Set db = session.CurrentDatabase

Set view = db.getview("($ALL)")

Set doc = view.GetFirstDocument

Set db1 = session.GetDatabase("pc58-LotusServer/v2solutions","FullJava")



While Not doc Is Nothing

	Set rtitem = doc.GetFirstItem( "Body" )

	If ( rtitem.Type = RICHTEXT ) Then

		Forall o In rtitem.EmbeddedObjects

			Msgbox (o.source)

			If ( o.Type = EMBED_ATTACHMENT ) Then

				Set itemA = doc.GetFirstItem( "Body" )

				Set doc1 = New NotesDocument( db1)

				Call itemA.CopyItemToDocument(doc1,"Body")

				doc1.form="mail"

				Call doc1.Save(False,True)

			End If

		End Forall

	End If

	Call doc.Remove(True)

	Call view.Refresh

	Set doc = view.GetFirstDocument

Wend

Regards

Sanjay

Subject: There is a document with multiple attachments & i have to create document for eact attachment.

Inside your Forall o In rtitem.EmbeddedObjectsloop you are copying the whole item to doc1. The item contains the 4 attachments.

Instead you will have to create a new rtitem in doc1, and embed the attachment in it.