Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Unable to remove attachments

Status
Not open for further replies.

wuneyej

Technical User
Jan 6, 2003
147
US
The following LotusScript will successfully copy attachments to the given directory, but the attachments remain embedded in the Notes documents, despite the code calling for their removal.

*************************
Sub Initialize
Dim s As New NotesSession
Dim DC As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As Variant

Set DC = s.CurrentDatabase.UnprocessedDocuments
Set Doc = DC.GetFirstDocument
Do Until Doc Is Nothing
Set rtitem = doc.GetFirstItem("ProposalAttachment")
If (rtitem.Type = RICHTEXT) Then
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
Call o.ExtractFile ("G:\Projects\Lotus_PAS_Attachments\" & o.Source)
Call o.Remove
End If
End Forall
End If
Set Doc = DC.GetNextDocument (Doc)
Loop

End Sub
**************************

Is there code other than Call o.Remove that I need to add? I'm at a loss.

JP
 
I've made some progress the last couple of days. Now I need my agent to create a new folder (based on a project number on the document), copy all attachments from the document to the newly created folder, and remove the attachments from the Lotus document.

So far, the agent successfully creates the new folder, copies the FIRST attachment to the new folder, and removes that FIRST attachment from the Lotus document. But the script generates a "path/file access error" when it gets to the second attachment.

What changes can be made to get the code to successfully create folder X, copy ALL the attachments from document X to folder X, and delete all embedded attachments from document X. Then move on to document Y, create folder Y, copy ALL attachments to folder Y, delete ALL attachments from document Y, and so on and so forth?

Here's what I have so far:

**********************************
Sub Initialize

Dim s As New NotesSession
Dim DC As NotesDocumentCollection
Dim doc As NotesDocument
Dim rtitem As Variant

Set DC = s.CurrentDatabase.UnprocessedDocuments
Set Doc = DC.GetFirstDocument
Do Until Doc Is Nothing
Set rtitem = doc.GetFirstItem("ProposalAttachment")
If (rtitem.Type = RICHTEXT) Then
Forall o In rtitem.EmbeddedObjects
If (o.Type = EMBED_ATTACHMENT) Then
Dim path As String
path="G:\Projects\Lotus_PAS_Attachments\"+Cstr(doc.ProposalNumber(0))
If (Dir$(path)="") Then
Mkdir(path)
End If
Call o.ExtractFile(path+"\"+o.Source)
Call o.Remove
Call doc.Save(True,True)
End If
End Forall
End If
Set Doc = DC.GetNextDocument (Doc)
Loop

End Sub
**********************************

I'd appreciate any help or advice.

JP
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top