Sub Click(Source As Button)
Dim session As New NotesSession
Dim db As NotesDatabase
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set doc = db.GetDocumentByID( "000021CA" )
If doc Is Nothing Then
Messagebox("Document not found")
End If
End Sub
Sub mergeSearch( arrayA As Variant, arrayB As Variant, _
db As NotesDatabase )
Dim doc As NotesDocument
Dim resultDoc As NotesDocument
Dim rtitem As NotesRichTextItem
Set resultDoc = New NotesDocument( db )
Set rtitem = New NotesRichTextItem( resultDoc, "Body" )
Forall noteIDa In arrayA
Forall noteIDb In arrayB
If (noteIDa = noteIDb) And (noteIDa <> "") Then
Set doc = db.GetDocumentByID( noteIDa )
Call rtitem.AppendDoclink( doc, _
doc.Subject( 0 ) )
End If
End Forall
End Forall
resultDoc.Subject = _
"Here's the results of two searches"
Call resultDoc.Send( False, "Anne Mackinnon" )
End Sub
上記のサブルーチンを使用すると、2 つの異なる検索条件に一致する他の文書へのリンクを含む「ニュースレター」文書を作成できます。
例えば、次のスクリプトが mergeSearch サブルーチンを呼び出すと、Anne Mackinnon は電子メールでメモを受信します。メールメモには現在のデータベースにある、単語「wheels」を含み、Subject アイテムに「bicycle」を持つ 1995 年 1 月 20 日以降に作成された文書へのリンクが含まれます。スクリプトは 2 つの検索を実行して、検索結果のコレクションを表す NoteID の配列を作成してから、mergeSearch を呼び出して残りの処理を実行します。
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim dateTime As NotesDateTime
Dim collectionA As NotesDocumentCollection
Dim collectionB As NotesDocumentCollection
Dim docA As NotesDocument
Dim docB As NotesDocument
Dim arrayA( 1 To 10 ) As String
Dim arrayB( 1 To 10 ) As String
Set db = session.CurrentDatabase
Set dateTime = New NotesDateTime( "01/20/95" )
Set collectionA = db.FTSearch( "wheels", 10 )
Set docA = collectionA.GetFirstDocument()
Set collectionB = db.Search _
( "@Contains( Subject; ""bicycle"" )", dateTime, 10 )
Set docB = collectionB.GetFirstDocument()
For i = 1 To collectionA.Count
arrayA( i ) = docA.NoteID
Set docA = collectionA.GetNextDocument(docA )
Next
For j = 1 To collectionB.Count
arrayB( j ) = docB.NoteID
Set docB = collectionB.GetNextDocument(docB)
Next
Call mergeSearch( arrayA, arrayB, db )
End Sub