LOTUSSCRIPT/COM/OLE CLASSES


Examples: WriteText method
This agent creates a file using the Subject item of the selected document for the file name, then writes the Body item of the selected document to it.

Sub Initialize
 Dim session As NotesSession
 Dim db As NotesDatabase
 Dim dc As NotesDocumentCollection
 Dim doc As NotesDocument
 Dim stream As NotesStream
 Dim pathname As String
 pathname = "c:\StreamFiles\"
 Set session = New NotesSession
 Set db = session.CurrentDatabase
 Set dc = db.UnprocessedDocuments
 Set doc = dc.GetFirstDocument
 Set stream = session.CreateStream
 pathname = pathname & doc.GetItemValue("Subject")(0) & ".txt"
 If Not stream.Open(pathname, "ASCII") Then
   Messagebox pathname,, "Open failed"
   Exit Sub
 End If
 If stream.Bytes <> 0 Then
   Messagebox pathname,, "File already exists and has content"
   Exit Sub
 End If
 Call stream.WriteText(doc.GetItemValue("Body")(0), EOL_CRLF)
 Call stream.Close
End Sub

See Also