Sample code for 30+ languages & platforms
AutoIt

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 AutoIt Downloads

AutoIt
Local $bSuccess = False

$oMime = ObjCreate("Chilkat.Mime")

;  Create a multipart/mixed entity.
$bSuccess = $oMime.NewMultipartMixed()
If ($bSuccess = False) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

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

;  Add a simple part so the multipart has content.
$oPart = ObjCreate("Chilkat.Mime")
$bSuccess = $oPart.SetBodyFromPlainText("First part.")
If ($bSuccess = False) Then
    ConsoleWrite($oPart.LastErrorText & @CRLF)
    Exit
EndIf

$bSuccess = $oMime.AppendPart($oPart)
If ($bSuccess = False) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite("Boundary = " & $oMime.Boundary & @CRLF)

Local $sMimeStr = $oMime.GetMime()
If ($oMime.LastMethodSuccess = False) Then
    ConsoleWrite($oMime.LastErrorText & @CRLF)
    Exit
EndIf

ConsoleWrite($sMimeStr & @CRLF)