Copy one attachment at a time

Hi guys,

I have some code that gets information about an attachment file, (size, source, etc) which is then stamped onto a new document, and the attachment copied to the new document.

This works fine with fields with only 1 attachment, but when there is 2 or more attachments, it created 2 documents (correct) each document has the different attachment size, source etc (correct) however each document, has both attachments on it, when i only need 1 attachment - relevent to the size, source etc that I have copied.

Is there anyway to get all objects for attachment 1, and copy attachment 1, then get all objects for attachment 2, and copy attachment 2 and so on?

Code is below… Thanks

Set rtItemAtt1 = thisDoc.GetFirstItem(“Attachments_Information”)

	If Not (rtItemAtt1 Is Nothing) Then

		If (rtItemAtt1.Type = RICHTEXT) Then

			If IsArray(rtItemAtt1.EmbeddedObjects) Then

			ForAll o In rtItemAtt1.EmbeddedObjects

				If (o.Type = EMBED_ATTACHMENT) Then

					

					'Get UID of eSupport document, title and size of attachment

					attUID = thisDoc.Universalid

					attTitle = o.Source

					attSize = o.FileSize

																

					'COPY VALUES TO NEW DOCUMENT

					Set copyDoc = copyDB.CreateDocument

					copyDoc.Form = "F_Attach"

					copyDoc.attTitle = attTitle

					copyDoc.attSize = attSize

					copyDoc.attUID = attUID

					copyDoc.AttDateTime = Now

					'This is not the secure tab section so say "no"

					copyDoc.attSecure = "No"

					'Copy attachment to new document

					Call rtItemAtt1.CopyItemToDocument(copyDoc,"attFile")

					Call copyDoc.Save(True, False)

					

				End If

			End ForAll

			End If

		End If

	End If

Subject: Copy one attachment at a time

Hi,

Don’t copy whole item by:

Call rtItemAtt1.CopyItemToDocument(copyDoc,“attFile”)

Use ExtractFile method instead to extract object to temp directory and then embed that object using EmbedObject method.

Regards,

Konrad