Perl
Chilkat2 Perl
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.
Chilkat Perl Downloads
use strict;
use warnings;
use Chilkat2;
my $mime = Chilkat2::Mime->new;
# Create a multipart/mixed entity.
my $success = $mime->NewMultipartMixed();
if (!$success) {
print $mime->LastErrorText, "\n";
exit;
}
# 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 0.
$mime->UseMmDescription(1);
# Add a simple part so the multipart has content.
my $part = Chilkat2::Mime->new;
$success = $part->SetBodyFromPlainText('First part.');
if (!$success) {
print $part->LastErrorText, "\n";
exit;
}
$success = $mime->AppendPart($part);
if (!$success) {
print $mime->LastErrorText, "\n";
exit;
}
print 'Boundary = ', $mime->Boundary, "\n";
my $mimeStr = $mime->GetMime();
if (!$mime->LastMethodSuccess) {
print $mime->LastErrorText, "\n";
exit;
}
print $mimeStr, "\n";