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
You could use the sub above to create a "newsletter" document that contains links to other documents that match two separate searches.
For example, when the following script calls the mergeSearch sub, Anne Mackinnon receives an e-mail memo containing links to documents in the current database that contain the word "wheels," have "bicycle" in the Subject item, and were created after January 20, 1995. The script performs two searches, constructs an array of NoteIDs representing the documents of the two resulting collections, and calls mergeSearch to do the rest.
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