CkPython
CkPython
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 CkPython Downloads
import sys
import chilkat
success = False
mime = chilkat.CkMime()
# Create a multipart/mixed entity.
success = mime.NewMultipartMixed()
if (success == False):
print(mime.lastErrorText())
sys.exit()
# Boundary is the raw boundary token, without surrounding quotation marks. Chilkat quotes it
# automatically in the serialized header when required.
mime.put_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.put_UseMmDescription(True)
# Add a simple part so the multipart has content.
part = chilkat.CkMime()
success = part.SetBodyFromPlainText("First part.")
if (success == False):
print(part.lastErrorText())
sys.exit()
success = mime.AppendPart(part)
if (success == False):
print(mime.lastErrorText())
sys.exit()
print("Boundary = " + mime.boundary())
mimeStr = mime.getMime()
if (mime.get_LastMethodSuccess() == False):
print(mime.lastErrorText())
sys.exit()
print(mimeStr)