Delete $File

Hi there,I have a problem with a special agent in context to load Pictures from a webInterface into a document.

In Case of special requests, i stored the File into a “Temporary” Document, which is deleted after the whole process. This Document has some other fields, which are not interesting here, BUT to get the special $File field copy into another document i remove all items except those, named “$FILE”, and then uses copyallitems

My Problem is, that currently the Items are removed, but there are two $File fields in the document, so both of them are copied. How can I identifie a $File field and remove it. I tried to get the file name with items.values(0) but it doesn’t worked.

Do you have some Ideas for that?

Subject: delete $File

Robert,

You can cycle through all the $FILE fields and delete them with this technique:

Dim doc As NotesDocument, item As NotesItem

Get handle to doc, then…

Set item = doc.GetFirstItem(“$FILE”)

Do While Not item Is Nothing

 Call item.Remove  ' Delete each $FILE field found.	

 Set item = doc.GetFirstItem("$FILE")  ' Get next $FILE field if there is one.

Loop

Ken A Collins

New York City

Subject: RE: delete $File

Thanks Ken,It worked fine.

Subject: RE: delete $File

Thank you for the quick response. Problematically you way would delete all of the $File-Items, but i need a special $File item left, to copy it.

------------------------$FILE ITEM1

Field Name: $FILE

Data Type: Attached Object

Data Length: 50 bytes

Seq Num: 1

Dup Item ID: 0

Field Flags: ATTACH SIGN SEAL SUMMARY

Object Type: File

Object ID: 000076FA

Object Length: 60031

File Name: img001460.jpg

Flags:

Host: UNKNOWN

Compression Type: NONE

Encoding Type:

File Attributes: RW PUBLIC

File Size: 60031

File Created: 19.03.2008 13:39:39

File Modified: 19.03.2008 13:39:39

------------------------$FILE ITEM2

Field Name: $FILE

Data Type: Attached Object

Data Length: 45 bytes

Seq Num: 1

Dup Item ID: 1

Field Flags: ATTACH SIGN SEAL SUMMARY

Object Type: File

Object ID: 000076FE

Object Length: 60031

File Name: ATTVBWNN

Flags:

Host: MSDOS/OS2

Compression Type: NONE

Encoding Type:

File Attributes: RW PUBLIC

File Size: 60031

File Created: 19.03.2008 13:39:39

File Modified: 19.03.2008 13:39:39

I didnt getted to handle to delete just one of them (in this case delete the one with “File Name: ATTVBWNN”

Subject: delete $File - code to determine attachement name

This does not do what you need, but should be enough to get you well on your way.

Function ValidateAttachement(CurrDocBackEnd As NotesDocument) As Boolean

Dim EmbedObjVar As Variant

Dim EmbedObj As NotesEmbeddedObject

Dim NRTItem As NotesRichTextItem

Dim ObjName As String

Dim ObjExt As String

Dim ObjLeft3 As String



'Check if any

If CurrDocBackEnd.HasEmbedded Then

	Set NRTItem = CurrDocBackEnd.GetFirstItem("Detail")

	EmbedObjVar  = NRTItem.EmbeddedObjects

	If Isempty(EmbedObjVar) Then

		ValidateAttachement = True

	Else

		Forall Obj In EmbedObjVar

			If ( Obj.Type = EMBED_ATTACHMENT ) Then

				ObjName = Obj.Name

				ObjExt = Ucase(Right(ObjName, 3))

				If ObjExt = "DAT" Then

					ObjLeft3 = Ucase(Left(ObjName, 3))

					If ObjLeft3 = "ATT" Then

						ValidateAttachement = False

						Exit Function

					Else

						ValidateAttachement = True

					End If

				Else

					ValidateAttachement = True

				End If

			End If

		End Forall

		

	End If

Else

	ValidateAttachement = True

End If

End Function

Subject: RE: delete $File - code to determine attachement name

Thank you so far, actually i have no access to my work, so i will try it in a few days, after Easter-Days.