例: CreateParentEntity 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 parent As NotesMIMEEntity
  Dim stream As Notesstream
  Set db = s.CurrentDatabase
  s.ConvertMIME = False ' Do not convert MIME to rich text
  Set stream = s.CreateStream
  Set dc = db.UnprocessedDocuments
  Set doc = dc.GetFirstDocument
  If doc Is Nothing Then Goto ExitSub
  Set mime = doc.GetMIMEEntity
  If Not(mime Is Nothing) Then
    If mime.ContentType <> "multipart" Then
      Set parent = mime.CreateParentEntity
    Else
      Set parent = mime
    End If
    Set mime = parent.CreateChildEntity
    Call stream.WriteText("Additional text." & _
    Chr(10) & Chr(10))
    Call mime.SetContentFromText(stream, _
    "text/plain", ENC_NONE)
    Call doc.Save(True, True)
  Else
    Messagebox "Not MIME",, doc.GetItemValue("Subject")(0)
  End If
ExitSub:
 s.ConvertMIME = True ' Restore conversion
End Sub