I am having trouble accessing the NotesDocument.Items array, and I can’t figure out why.Here is the situation: We have a database that allows users to embed jpg files into rich text fields by the name of PageBody. This database routinely gets too large for the server, and the users don’t have time to go back and remove old pictures. We want to have a script that searches through the documents in the database and removes only the jpg files, but leaves the document itself in place.
The script that I wrote yesterday was working fairly well (this was a test script, and does not yet have the “Remove” method), but would occassionally throw a “Type Mismatch” on the first Forall loop. When I looked at the document properties in debugger, “Items” did not have a twistie, so my assumption was that for whatever reason I was not allowed to access the items array for that particular document. Since having a few docs “slip by” this agent wouldn’t be a problem, I added the IsArray test so that I could simply bypass the docs that would throw this error.
The problem I have now, though, is that none of the documents in the database will allow my script to see the Items array, even when I confirm that I can see the items in a document properties window using the same ID.
Can anyone help with this issue? (Note: some of the variables in the script are just placeholders for some breaks in debugger.)
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Set db = session.GetDatabase("xxxx", False)
Dim dc As NotesDocumentCollection
Set dc = db.AllDocuments
Dim doc As NotesDocument
Set doc = dc.GetFirstDocument
Dim Oname As String
Dim test As String
Dim success As String
Dim counter As Integer
counter = 0
Dim fSize As Long
fSize = 0
Dim rt As NotesRichTextItem
Dim eo As NotesEmbeddedObject
Dim crdate As String
Dim nowdate As String
nowdate = Cstr(Now)
Dim age As Integer
Dim itemcount As Integer
While Not (doc Is Nothing)
If doc.HasItem("PageBody") Then
If Isarray(doc.Items) Then
crdate = Cstr(doc.Created)
age = Datevalue(nowdate) - Datevalue(crdate)
If age > 150 Then
'items = doc.items
If doc.HasEmbedded Then
Forall i In doc.items
If i.name = "PageBody" Then
Set rt = i
Forall e In rt.EmbeddedObjects
oName = e.Name
test = Strright(oName, ".")
If test = "JPG" Then
success = "True"
counter = counter + 1
fSize = fSize + e.FileSize
End If
End Forall
End If
End Forall
End If
End If
End If
End If
Set doc = dc.GetNextDocument(doc)
Wend
Dim statement As String
statement = Cstr(counter) & " files located. Total size - " & Cstr(fSize)
End Sub