Examples: GetContentAsText method

This agent gets the content of a "text/plain" MIME entity and saves it to a TXT file.

Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim mime As NotesMIMEEntity
  Dim stream As NotesStream
  Set db = s.CurrentDatabase
  s.ConvertMIME = False ' Do not convert MIME to rich text
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  If Not(doc Is Nothing) Then
    Set mime = doc.GetMIMEEntity
    If Not(mime Is Nothing) Then
      If mime.ContentType = "text" And _
      mime.ContentSubtype = "plain" Then
        Set stream = s.CreateStream
        pathname$ = "c:\lotus\notes\data\temp.txt"
        If Not stream.Open(pathname$, "us-ascii") Then
          Messagebox pathname$,, "Open failed"
          Goto ExitSub
        End If
        Call stream.Close();
        Call mime.GetContentAsText(stream)
        Messagebox "Not plain text",, _
      End If
      Messagebox "Not MIME",, doc.GetItemValue("Subject")(0)
    End If
  End If
  s.ConvertMIME = True ' Restore conversion
End Sub