例: CreateChildEntity method

  1. 次のエージェントは、メールメモに適したマルチパート MIME エンティティを作成します。親エンティティには、Domino メールメモを定義するヘッダーが組み込まれます。2 つの子エンティティにはメモのコンテントが組み込まれます。
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim body As NotesMIMEEntity
      Dim header As NotesMIMEHeader
      Dim child As NotesMIMEEntity
      Dim stream As NotesStream
      Set db = s.CurrentDatabase
      Set stream = s.CreateStream
      s.ConvertMIME = False
      Set doc = db.CreateDocument
      
      REM Create the parent entity
      Call doc.ReplaceItemValue("Form", "Memo")
      Set body = doc.CreateMIMEEntity
      REM Create header for Content-Type
      Set header = body.CreateHeader("Content-Type")
      Call header.SetHeaderVal("multipart/mixed")
      REM Create additional headers for mail message
      Set header = body.CreateHeader("Subject")
      Call header.SetHeaderVal("MIME multipart message")
      Set header = body.CreateHeader("To")
      Call header.SetHeaderVal("Roberta Person")
      
      REM Create child entity
      Set child = body.CreateChildEntity
      Call stream.WriteText("Text of message for child 1." & _
      Chr(10) & Chr(10))
      Call child.SetContentFromText(stream, _
      "text/plain", ENC_NONE)
      Call stream.Truncate
      
      REM Create another child entity
      Call stream.WriteText("Text of message for child 2.")
      Set child = body.CreateChildEntity
      Call child.SetContentFromText(stream, _
      "text/plain", ENC_NONE)
      Call doc.Send(False)
      s.ConvertMIME = True ' Restore conversion
    End Sub
  2. 次のエージェントは、子エンティティが 2 つあるマルチパート MIME エンティティを作成します。子エンティティは逆順で配置されます。
    Sub Initialize
      Dim s As New NotesSession
      Dim db As NotesDatabase
      Dim doc As NotesDocument
      Dim body As NotesMIMEEntity
      Dim header As NotesMIMEHeader
      Dim child As NotesMIMEEntity
      Dim stream As NotesStream
      Set db = s.CurrentDatabase
      Set stream = s.CreateStream
      s.ConvertMIME = False
      Set doc = db.CreateDocument
      
      REM Create the parent entity
      Call doc.ReplaceItemValue("Form", "Main Form")
      Set body = doc.CreateMIMEEntity
      REM Create header for Content-Type
      Set header = body.CreateHeader("Content-Type")
      Call header.SetHeaderVal("multipart/mixed")
      REM Create additional headers for mail message
      Set header = body.CreateHeader("Subject")
      Call header.SetHeaderVal("MIME multipart message")
      
      REM Create child entity
      Set child = body.CreateChildEntity
      Call stream.WriteText("Text of message for child 1.")
      Call child.SetContentFromText(stream, _
      "text/plain", ENC_NONE)
      Call stream.Truncate
      
      REM Create another child entity
      Call stream.WriteText("Text of message for child 2." & _
      Chr(10) & Chr(10))
      Set child = body.CreateChildEntity(child)
      Call child.SetContentFromText(stream, _
      "text/plain", ENC_NONE)
      Call doc.Save(True, True)
      s.ConvertMIME = True ' Restore conversion
    End Sub