このエージェントは、最後に実行された後に更新された、現在のデータベースにあるすべてのデータ文書を取得します。getModifiedDocuments が動作するたびに、データベース終了時刻がプロフィール文書に保存されます。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim profile As NotesDocument
Dim untilTime As NotesDateTime
Set db = session.CurrentDatabase
' Check UntilTime in profile document
Set profile = db.GetProfileDocument("Profile")
If profile.HasItem("UntilTime") Then
' Start processing from UntilTime
Set untilTime = profile.GetItemValueDateTimeArray("UntilTime")(0)
Set dc = db.GetModifiedDocuments(untilTime, DBMOD_DOC_DATA)
Else
' First time through get all documents
Set dc = db.GetModifiedDocuments(, DBMOD_DOC_DATA)
End If
If dc.Count > 0 Then
' Display LastModified and Subject from each document
Set doc = dc.GetFirstDocument
While Not(doc Is Nothing)
Messagebox doc.GetItemValue("Subject")(0),, doc.LastModified
Set doc = dc.GetNextDocument(doc)
Wend
Else
' If nothing modified since last time
If profile.HasItem("UntilTime") Then
Messagebox "No documents modified",, untilTime.LocalTime
Else
Messagebox "No documents modified",, "Beginning"
End If
End If
' Write UntilTime back to profile document
Call profile.ReplaceItemValue("UntilTime", dc.UntilTime)
Call profile.Save(True, True, True)
End Sub