Sample code for 30+ languages & platforms
PowerBuilder

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

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_Part
string ls_MimeStr

li_Success = 0

loo_Mime = create oleobject
li_rc = loo_Mime.ConnectToNewObject("Chilkat.Mime")
if li_rc < 0 then
    destroy loo_Mime
    MessageBox("Error","Connecting to COM object failed")
    return
end if

//  Create a multipart/mixed entity.
li_Success = loo_Mime.NewMultipartMixed()
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    return
end if

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

//  Add a simple part so the multipart has content.
loo_Part = create oleobject
li_rc = loo_Part.ConnectToNewObject("Chilkat.Mime")

li_Success = loo_Part.SetBodyFromPlainText("First part.")
if li_Success = 0 then
    Write-Debug loo_Part.LastErrorText
    destroy loo_Mime
    destroy loo_Part
    return
end if

li_Success = loo_Mime.AppendPart(loo_Part)
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    destroy loo_Part
    return
end if

Write-Debug "Boundary = " + loo_Mime.Boundary

ls_MimeStr = loo_Mime.GetMime()
if loo_Mime.LastMethodSuccess = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    destroy loo_Part
    return
end if

Write-Debug ls_MimeStr


destroy loo_Mime
destroy loo_Part