convertToMIME (NotesDocument - JavaScript™)
Converts a document in Notes® format to MIME format similar to a mail router.
Defined in
NotesDocumentSyntax
convertToMIME() : void
convertToMIME(conversiontype:int) : void
Parameter | Description |
---|---|
conversiontype |
One of the following:
|
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();
}