例: GetPrevEntity method

次のエージェントは、マルチパートエンティティの最後の分岐の最後から MIME エンティティをすべて逆順で取得します。

Sub Initialize
  Dim s As New NotesSession
  Dim db As NotesDatabase
  Dim dc As NotesDocumentCollection
  Dim doc As NotesDocument
  Dim mime As NotesMIMEEntity
  Dim child 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
      REM Drill down to last child at end of first branch
      Set child = mime.GetNextEntity(SEARCH_BREADTH)
      While Not(child Is Nothing)
        Set mime = child
        Set child = mime.GetNextEntity(SEARCH_BREADTH)
      Wend
      REM Get content of all entities from end level 
      REM of first branch in reverse order
      Do
        If mime.ContentType = "multipart" Then
          Messagebox mime.Preamble,, "Parent"
        Else
          Messagebox mime.ContentAsText,, "Child"
        End If
        Set mime = mime.GetPrevEntity(SEARCH_BREADTH)
      Loop Until mime Is Nothing
    Else
      Messagebox "Not MIME",, doc.GetItemValue("Subject")(0)
    End If
  End If
  s.ConvertMIME = True ' Restore conversion
End Sub