Removing attachments via lotusScript

Hi again,

I’m trying to remove an attachment in a doc via LS. This code removes the attachment from the RTI, but it is storing the attachment in the doc itself. How do I prevent that?

Thanks?

	If Not Isempty(surveyRtitem.EmbeddedObjects) Then			

		Forall blah In surveyRtitem.EmbeddedObjects

			Call blah.remove

		End Forall			

	End If

I tried to follow with …

	If survey.HasEmbedded Then

		Forall o In survey.EmbeddedObjects

			o.remove

		End Forall

	End If

but that fails.

Subject: Removing attachments via lotusScript

The attachments should actually be gone when you save the document (it seems that the Remove isn’t “fully committed” until the save – at least from my experience with attachment-moving WQS agents in 6.x.x, where the attachment would wind up with an ATTnnnnn name if the doc was not saved before re-attaching).

Subject: RE: Removing attachments via lotusScript

Thanks Stan,

I thought so too, that is what help says, but it was embedding it in the doc for some reason. The 2nd code I posted works ok.

As always - Thanks!!

Subject: RE: Removing attachments via lotusScript

I notice that your fix was to save the document before looking at the document’s EmbeddedObjects collection – that is what I was trying to say in my posting. Your Remove will disassociate the attachments from the rich text field, but they are still part of the document until a save is called (at least in 6.x.x – in R5 the attachments were gone immediately, and the behaviour may have been fixed in more recent versions).

Subject: Removing attachments via lotusScript

got it.

I do this after removing the blah embedded object …

	Call survey.Save(True, False)

	

	If survey.HasEmbedded Then			

		Set myItem = survey.GetFirstItem("$File")			

		While Not myItem Is Nothing				

			Call myItem.Remove				

			Set myItem = survey.GetFirstItem("$File")								

		Wend			

	End If