次のエージェントは、現在 (または最初に) 選択されている文書の Body アイテムにユーザーが入力した文字列と一致する最初の文字列を検索します。
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim body As NotesRichTextItem
Dim rtnav As NotesRichTextNavigator
Dim rtrange As NotesRichTextRange
Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
If dc.Count = 0 Then
Messagebox "No document selected",, "No doc"
Exit Sub
End If
Set doc = dc.GetFirstDocument
Set body = doc.GetFirstItem("Body")
Set rtnav = body.CreateNavigator
Set rtrange = body.CreateRange
searchString$ = Inputbox$("Enter the search string", _
"Search string")
If searchString$ = "" Then Exit Sub
If rtnav.FindFirstString(searchString$, _
RT_FIND_CASEINSENSITIVE) Then
Call rtrange.SetBegin(rtnav)
Messagebox rtrange.TextRun,, searchString$
Else
Messagebox searchString$,, "String not found"
End If
End Sub