JavaScript
JavaScript
MIME Multipart Boundary and Preamble Properties
See more MIME Examples
Demonstrates the Boundary property, which gets or sets the raw boundary token of a multipart entity (without surrounding quotation marks), and UseMmDescription, which controls whether the conventional preamble text is emitted when serializing a multipart entity.
Background. A multipart boundary separates the constituent parts. Chilkat quotes the token automatically in the header when required. The preamble is ignored by MIME-aware readers and is off by default.
Note
This example is intended for running within a Chilkat.Js embedded JavaScript engine. All Chilkat JavaScript examples require Chilkat
v11.4.0 or greater.
var success = false;
var mime = new CkMime();
// Create a multipart/mixed entity.
success = mime.NewMultipartMixed();
if (success == false) {
console.log(mime.LastErrorText);
return;
}
// Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
// automatically in the serialized header when required.
mime.Boundary = "example-boundary";
// UseMmDescription controls whether the conventional preamble text
// "This is a multi-part message in MIME format." is emitted. The default is false.
mime.UseMmDescription = true;
// Add a simple part so the multipart has content.
var part = new CkMime();
success = part.SetBodyFromPlainText("First part.");
if (success == false) {
console.log(part.LastErrorText);
return;
}
success = mime.AppendPart(part);
if (success == false) {
console.log(mime.LastErrorText);
return;
}
console.log("Boundary = " + mime.Boundary);
var mimeStr = mime.GetMime();
if (mime.LastMethodSuccess == false) {
console.log(mime.LastErrorText);
return;
}
console.log(mimeStr);