Problem in removing Attachment

Hi all,I have lot of RTF fields in my odc, I would like to extract the atatchment and remove the atachments only on certain RTF field.

I created setting doc and mention the RTF fields name where i would liek to remove attachment. It works fine, but the problem is If i have same attachment in 2 different RTF or on the same RTF,then my code is not working fine, it some times remove the attachment wrongly. I noticed that if i do same attachment in a doc, notes internaly change the name for any one of the atatchment. How to over come this.

Below is my code.some declaration and soem part of code i removed for readablity purpose.

Set rtitem = doc.getfirstitem(t.name)

Set nav = rtitem.createnavigator

attachavailable = nav.findfirstelement(RTELEM_TYPE_FILEATTACHMENT)

If attachavailable = True Then

Forall obj In rtitem.embeddedobjects

If obj.type = EMBED_ATTACHMENT And attachavailable= True Then

object = rtitem.embeddedobjects

If Not Isempty(object) Then

Forall o In rtitem.embeddedobjects

If o.type = EMBED_ATTACHMENT Then

Set object = rtitem.GetEmbeddedObject( o.source )

Call o.extractfile(localpath) Forall tt In doc.Items

If tt.name=“$FILE” Then

Set ob = doc.GetAttachment(tt.values(0))

If ((ob.name = o.name) And (fsizeforrem = ob.filesize))Then

Call ob.remove

Call tt.remove

Exit Forall

End If

End If

regds

soma