次のエージェントは、ストリームを作成し、選択されている文書の Body アイテムのテキスト値を書き込み、ストリーム内の位置を変更し、ストリームを読み込みます。
Sub Initialize
Dim session As NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Dim stream As NotesStream
Set session = New NotesSession
Set db = session.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
REM Create stream and display properties
Set stream = session.CreateStream
Messagebox "Bytes = " & stream.Bytes & Chr(13) & _
"Charset = " & stream.Charset & Chr(13) & _
"IsEOS = " & stream.IsEOS & Chr(13) & _
"Position = " & stream.Position,, "After creating stream"
REM Write text of Body item to stream and display properties
Call stream.WriteText(doc.GetItemValue("Body")(0))
Messagebox "Bytes = " & stream.Bytes & Chr(13) & _
"Charset = " & stream.Charset & Chr(13) & _
"IsEOS = " & stream.IsEOS & Chr(13) & _
"Position = " & stream.Position,, "After writing to stream"
REM Set position to 0 and display properties
stream.Position = 0
Messagebox "Bytes = " & stream.Bytes & Chr(13) & _
"Charset = " & stream.Charset & Chr(13) & _
"IsEOS = " & stream.IsEOS & Chr(13) & _
"Position = " & stream.Position,, _
"After setting position of stream"
REM Read text from stream
Messagebox stream.ReadText(),, "Text read from stream"
End Sub