setContentFromBytes (NotesMIMEEntity - JavaScript)

Sets the content of the current MIME entity from an uninterpreted byte stream.

Defined in

NotesMIMEEntity

Syntax

setContentFromBytes(stream:NotesStream, contentType:string, encoding:int) : void
Parameter Description
stream The byte input. This input replaces any existing content. If the stream is empty, any current content is removed.
contentType Content type/subtype of input. This parameter generates a Content-Type header.
int encoding The MIME transfer encoding, which should reflect the encoding of the input stream. This parameter generates a Content-Transfer-Encoding header. See encodeContent.
  • NotesMIMEEntity.ENC_BASE64 (1727) -- Content-Transfer-Encoding is "base64"
  • NotesMIMEEntity.ENC_EXTENSION (1731) -- Content-Transfer-Encoding is user-defined
  • NotesMIMEEntity.ENC_IDENTITY_7BIT (1728) -- Content-Transfer-Encoding is "7bit"
  • NotesMIMEEntity.ENC_IDENTITY_8BIT (1729) -- Content-Transfer-Encoding is "8bit"
  • NotesMIMEEntity.ENC_IDENTITY_BINARY (1730) -- Content-Transfer-Encoding is "binary"
  • NotesMIMEEntity.ENC_NONE (1725) -- no Content-Transfer-Encoding header
  • NotesMIMEEntity.ENC_QUOTED_PRINTABLE (1726) -- Content-Transfer-Encoding is "quoted-printable"

Usage

This method sets the stream Position at end of stream.

Examples

This button creates a document in MIME format. The MIME content is one .gif file.
var stream:NotesStream = session.createStream();
// Do not automatically convert MIME to rich text
session.setConvertMIME(false);
var doc:NotesDocument = database.createDocument();
doc.replaceItemValue("Form", "main");
var body:NotesMIMEEntity = doc.createMIMEEntity();
var header:NotesMIMEHeader = body.createHeader("Subject");
header.setHeaderVal("MIME image from GIF file");
if (stream.open("c:\\notes\\data\\folder.gif", "binary")) {
	if (stream.getBytes() != 0) {
		body.setContentFromBytes(stream, "image/gif",
		NotesMIMEEntity.ENC_IDENTITY_BINARY);
	} else requestScope.status = "c:\\lotus\\notes\\data\\folder.gif has no content";
} else requestScope.status = "Error opening c:\\notes\\data\\folder.gif";
stream.close();
doc.save(true, true);
// Restore conversion
session.setConvertMIME(true);