Examples: AllDocuments property (NotesDatabase - LotusScript®)
- This script gets a collection of every document in the current
database. For example, if there are 56 documents in the database,
AllDocuments returns a collection with a Count property of 56.
Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Dim n As Integer Set db = session.CurrentDatabase Set collection = db.AllDocuments n = collection.Count
- This action script removes all file attachments from the Body
item of every document in the current database. The script examines
each document in the collection returned by AllDocuments and, if the
Body item for the document contains a file attachment, calls the sub
detachFiles, which detaches the file(s) to a directory on drive C.
Sub Initialize Dim session As New NotesSession Dim db As NotesDatabase Dim collection As NotesDocumentCollection Dim doc As NotesDocument Set db = session.CurrentDatabase Set collection = db.AllDocuments Set doc = collection.GetFirstDocument() While Not(doc Is Nothing) If doc.HasEmbedded Then Call detachFiles( doc ) End If Set doc = collection.GetNextDocument(doc) Wend End Sub Sub detachFiles( doc As NotesDocument ) Dim rtitem As Variant Set rtitem = doc.GetFirstItem( "Body" ) Forall o In rtitem.EmbeddedObjects If o.Type = EMBED_ATTACHMENT Then Call o.ExtractFile( "c:\newfiles\" & o.Source ) Call o.Remove Call doc.Save( True, True ) End If End Forall End Sub