developerWorks  >  Lotus  >  Forums & community  >  Notes/Domino 6 and 7 Forum

Notes/Domino 6 and 7 Forum

developerWorks




Trying to copy the attachments from one document to another document
Alena Smart 08/24/2016 03:52 PM
Domino Designer 7.0.3 FP1 All Platforms


Hi, I need a little help in copying all the attachments of a filed to a new document, If I have 2 files in the field then I should have two documents created.

here is the code I am using,

Dim vAttachments As NotesView
Dim CollDocAtt As NotesDocumentCollection
Dim doc As NotesDocument
Dim docAttachment As NotesDocument
Dim rtitem As NotesRichTextItem
Dim rtitemATT As NotesRichTextItem
Set docAttachment = dbAtttachment.CreateDocument
Set vAttachments = db.GetView("Attachments")
Set CollDocAtt = vAttachments.GetAllDocumentsByKey("1") ' Lin")
Set doc = CollDocAtt.GetFirstDocument

Do Until doc Is Nothing
' For all attachments in the doc we create a document in the other DB

ForAll item In doc.Items
If Item.type = RICHTEXT Then

Set rtitem = doc.GetFirstItem( Item.Name )
If ( rtitem.Type = RICHTEXT ) Then
If rtitem.values <> "" Then

ForAll o In rtitem.EmbeddedObjects ' loop and creat a doc for eatch attachments

Set docAttachment = New NotesDocument( dbAtttachment )
docAttachment.Form = "Attachments"
docAttachment.Subject = doc.Part_No(0)
stop
Call item.CopyItemToDocument(docAttachment, "Body")' except that this copies the holl field and not just the files of it.

Call docAttachment.Save( True, True )


End ForAll
End If
End If

End If
End ForAll

Stop
Set doc = CollDocAtt.GetNextDocument(doc)

Loop


End Function

thanks for any help you can give me.

Alena

Go back