convertToMIME (NotesDocument - JavaScript)

Converts a document in Notes® format to MIME format similar to a mail router.

Defined in

NotesDocument

Syntax

convertToMIME() : void

convertToMIME(conversiontype:int) : void

convertToMIME(conversiontype:int, options:int) : void

Parameter Description
conversiontype One of the following:
  • NotesDocument.CVT_RT_TO_PLAINTEXT 1produces MIME output with a Text/Plain part that is a representation of the Notes® rich text. Everything but text contained in rich text is lost. For tables, a crude approximation is made using non-graphic characters.
  • NotesDocument.CVT_RT_TO_HTML 2 produces MIME output with a Text/HTML part that is a representation of the Notes® rich text. Some data loss is possible in the rendering. Improvements in fidelity may occur at any time.
  • NotesDocument.CVT_RT_TO_PLAINTEXT_AND_HTML 3 (default) produces MIME output with two renditions of the Notes® rich text: a Text/Plain part and a Text/HTML part. The characteristics of each stream are the same as their corresponding descriptions above. This is useful when the target audience may or may not have an HTML-capable mail reader, or can receive only text.
options Reserved.

Usage

The document's form is evaluated and the fields are used in the MIME conversion.

The conversion of rich text is imperfect.

Examples

This button mails a document in MIME format.
try {

// requestScope.sendto is a list box allowing multiple entries - returns java.util.ArrayList
// stop processing if sendto is empty
if (requestScope.sendto.isEmpty()) {
	requestScope.status = "No sender(s) specified";
	return;
}
var sendto = new java.util.Vector(requestScope.sendto);
var memo:NotesDocument = database.createDocument();memo.con
memo.appendItemValue("Form", "Memo");
// requestScope.subject is an edit box - returns string
memo.appendItemValue("Subject", requestScope.subject);
// requestScope.body is rich text - returns com.ibm.xsp.http.MimeMultipart
// do not create mime entity if body is null
if (requestScope.body != null) {
	// stream html from body to mime entity
	session.setConvertMime(false);
	var stream = session.createStream();
	stream.writeText(requestScope.body.getHTML());
	var body = memo.createMIMEEntity("Body");
	body.setContentFromText(stream,"text/html;charset=UTF-8", 1725);
	stream.close();
	memo.closeMIMEEntities(true);
	session.setConvertMime(true);
}

// send memo and report status
memo.convertToMIME(NotesDocument.CVT_RT_TO_HTML);
memo.send(false, sendto); // same as memo.send(sendto);
requestScope.status = "Message sent\n";

} catch(e) {
	requestScope.status = e.toString();
}