createMIMEEntity (NotesDocument - JavaScript)

Creates an uninitialized top-level MIME entity in a document.

Defined in

NotesDocument

Syntax

createMIMEEntity() : NotesMIMEEntity

createMIMEEntity(itemName:string) : NotesMIMEEntity

Parameter Description
itemName The name of the item containing the MIME entity. Body is the default.
Return value Description
NotesMIMEEntity The new MIME entity.

Usage

An item created with this method is of type MIME_PART.

To initialize the MIME entity, provide some content and save the containing document.

A MIME entity named Body (case insensitive) gets special support as a Domino® mail message. In particular, non-Content headers become items in the document. If you specify an item name other than Body, the containing document cannot be mailed.

On an XPage, a rich text control is of type com.ibm.xsp.http.MimeMultipart. Its getHTML method gets the content of the rich-text control as XML. You can use this XML in setContentFromText to initialize a new NotesMIMEEntity object.

A rich text control set from getContentAsText is not immediately accessible as a com.ibm.xsp.http.MimeMultipart object and programmatic access returns null. The user must first make an edit in the control.

Examples

This button mails a document in MIME format. Also see send.
var stream:NotesStream = session.createStream();
session.setConvertMime(false); // do not convert mime to rich text
var doc:NotesDocument = database.createDocument();
doc.appendItemValue("Form", "Memo");
var body:NotesMIMEEntity = doc.createMIMEEntity();
var header:NotesMIMEHeader = body.createHeader("Subject");
if (!header.setHeaderVal("MIME message")) {
	requestScope.status = "Cannot set header val for Subject";
	return;
}
header = body.createHeader("To");
if (!header.setHeaderVal(requestScope.query)) { // address of mail recipient
	requestScope.status = "Cannot set header val for To";
	return;
}
stream.writeText("This is the text of the message.");
body.setContentFromText(stream, "text/plain;charset=UTF-8", NotesMIMEEntity.ENC_NONE);
doc.send();
session.setConvertMime(true); // restore coversion
The following button creates a document from content on the current XPage.
var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "main");
doc.replaceItemValue("subject", requestScope.subject);
if (requestScope.body != null) {
	//requestScope.body is bound to an inputRichText control
	var body:com.ibm.xsp.http.MimeMultipart = requestScope.body;
	var stream:NotesStream = session.createStream();
	stream.writeText(body.getHTML());
	var entity:NotesMIMEEntity = doc.createMIMEEntity("body");
	entity.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
	stream.close();
} else {
	requestScope.status = "no content";
}
doc.save();