createChildEntity (NotesMIMEEntity - JavaScript)

Creates a MIME entity and inserts it into the list of child MIME entities.

Defined in

NotesMIMEEntity

Syntax

createChildEntity() : NotesMIMEEntity

createChildEntity(nextSibling:NotesMIMEEntity) : NotesMIMEEntity

Parameter Description
nextSibling An existing child of the calling MIME entity. If this parameter is specified, the new MIME entity is positioned ahead of it.
Return value Description
NotesMIMEEntity The child MIME entity.

Usage

A multipart MIME entity consists of parent and child entities. A parent can be a child. The child entities of a parent form a sequential list.

This method establishes the calling entity as a parent and the new entity as its child.

If the parent has no existing child entity, the new entity becomes the first child. If nextSibling is specified, this entity is placed ahead of it. Otherwise, this entity follows the last existing child entity.

If the parent's content type is multipart, the existing content type/subtype is retained; otherwise, multipart/mixed is imposed. If the parent's content type is multipart and the boundary parameter is specified, the existing boundary is retained; otherwise, a boundary is generated. The exception is that a content type/subtype of message/rfc822 is retained with no boundary.

The parent entity should contain no content. Any content is lost. You can include a preamble.

Examples

This button creates a multipart MIME entity and sends it as a mail memo.
var stream:NotesStream = session.createStream();
// Do not automatically convert MIME to rich text
session.setConvertMIME(false);
var doc:NotesDocument = database.createDocument();
// Create parent entity
doc.replaceItemValue("Form", "Memo");
var body:NotesMIMEEntity = doc.createMIMEEntity();
var header:NotesMIMEHeader = body.createHeader("Content-Type");
header.setHeaderVal("multipart/mixed");
header = body.createHeader("Subject");
header.setHeaderVal("MIME message");
header = body.createHeader("To");
header.setHeaderVal(requestScope.query);
// Create first child entity
var child:NotesMIMEEntity = body.createChildEntity();
stream.writeText("Text of message for child 1.\n");
child.setContentFromText(stream, "text/plain", NotesMIMEEntity.ENC_NONE);
stream.truncate();
// Create second child entity
child = body.createChildEntity();
stream.writeText("Text of message for child 2.");
child.setContentFromText(stream, "text/plain", NotesMIMEEntity.ENC_NONE);
doc.send(false);
// Restore conversion
session.setConvertMIME(true);
This button creates a multipart MIME entity and sends it as a mail memo, as above, but positions the second child in front of the first.
var stream:NotesStream = session.createStream();
// Do not automatically convert MIME to rich text
session.setConvertMIME(false);
var doc:NotesDocument = database.createDocument();
// Create parent entity
doc.replaceItemValue("Form", "Memo");
var body:NotesMIMEEntity = doc.createMIMEEntity();
var header:NotesMIMEHeader = body.createHeader("Content-Type");
header.setHeaderVal("multipart/mixed");
header = body.createHeader("Subject");
header.setHeaderVal("MIME message");
header = body.createHeader("To");
header.setHeaderVal(requestScope.query);
// Create first child entity
var child:NotesMIMEEntity = body.createChildEntity();
stream.writeText("Text of message for child 1.\n");
child.setContentFromText(stream, "text/plain", NotesMIMEEntity.ENC_NONE);
stream.truncate();
// Create second child entity
child = body.createChildEntity(child);
stream.writeText("Text of message for child 2.\n");
child.setContentFromText(stream, "text/plain", NotesMIMEEntity.ENC_NONE);
doc.send(false);
// Restore conversion
session.setConvertMIME(true);