setContentFromBytes (NotesMIMEEntity - JavaScript™)
Sets the content of the current MIME entity from an uninterpreted byte stream.
Defined in
NotesMIMEEntitySyntax
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.
|
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);