Examples: Add method
This example creates a note collection from documents in the current database. Only documents containing the word "test" in the subject field are included. A NotesDocument is used as the method parameter. The collection is exported to the file filename.
Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim stream As NotesStream
Dim exporter As NotesDXLExporter
Dim nc As NotesNoteCollection
Dim dc As NotesDocumentCollection
Dim i As Integer
Dim c As Integer
Dim doc As NotesDocument
Dim subj As Variant
Dim filename As String
REM Create an empty note collection
REM from the current database
Set db = session.CurrentDatabase
path$ = "c:\dxl\"
filename$ = Left(db.FileName, Len(db.FileName) - 3) & "dxl"
filename$ = path$ & filename$
Set nc = db.CreateNoteCollection(False)
Call nc.BuildCollection
c = nc.Count
REM Search for specific documents
Set dc = db.AllDocuments
Set doc = dc.GetFirstDocument
While Not (doc Is Nothing)
subj = doc.GetItemValue("Subject")
If Not findTest(subj(0))(0) = 0 Then
REM Modify the collection
Call nc.Add(doc)
End If
Set doc = dc.GetNextDocument(doc)
Wend
REM Export note collection as DXL
Set stream = session.CreateStream
If Not stream.Open(filename) Then
Messagebox "Cannot open " & filename,, "Error"
Exit Sub
End If
Call stream.Truncate
Set exporter = session.CreateDXLExporter(nc, stream)
Call exporter.Process
If nc.Count - c > 0 Then
Messagebox Cstr(nc.Count-c) & " documents added", , _
filename
End If
End Sub
Function findTest(value As String)
findTest = Evaluate( "@Contains (""" _
+ Ucase$(value) _
+ """; """ _
+ "TEST"+""") ")
End Function