Sample code for 30+ languages & platforms
Visual FoxPro

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 Visual FoxPro Downloads

Visual FoxPro
LOCAL lnSuccess
LOCAL loMime
LOCAL loPart
LOCAL lcMimeStr

lnSuccess = 0

loMime = CreateObject('Chilkat.Mime')

*  Create a multipart/mixed entity.
lnSuccess = loMime.NewMultipartMixed()
IF (lnSuccess = 0) THEN
    ? loMime.LastErrorText
    RELEASE loMime
    CANCEL
ENDIF

*  Boundary is the raw boundary token, without surrounding quotation marks.  Chilkat quotes it
*  automatically in the serialized header when required.
loMime.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.
loMime.UseMmDescription = 1

*  Add a simple part so the multipart has content.
loPart = CreateObject('Chilkat.Mime')
lnSuccess = loPart.SetBodyFromPlainText("First part.")
IF (lnSuccess = 0) THEN
    ? loPart.LastErrorText
    RELEASE loMime
    RELEASE loPart
    CANCEL
ENDIF

lnSuccess = loMime.AppendPart(loPart)
IF (lnSuccess = 0) THEN
    ? loMime.LastErrorText
    RELEASE loMime
    RELEASE loPart
    CANCEL
ENDIF

? "Boundary = " + loMime.Boundary

lcMimeStr = loMime.GetMime()
IF (loMime.LastMethodSuccess = 0) THEN
    ? loMime.LastErrorText
    RELEASE loMime
    RELEASE loPart
    CANCEL
ENDIF

? lcMimeStr

RELEASE loMime
RELEASE loPart