Sample code for 30+ languages & platforms
PowerBuilder

Create a multipart/mixed MIME Entity

See more MIME Examples

Demonstrates the Chilkat Mime.NewMultipartMixed method, which initializes the object as an empty multipart/mixed entity, clearing any existing content. It takes no arguments; child parts are then appended.

Note: The file paths are relative to the application's current working directory. Absolute paths may also be used. Supply the paths appropriate to your own environment.

Background: multipart/mixed is the container for independent parts shown one after another — the classic "message body plus attachments" layout. Each child is its own distinct content, unlike multipart/alternative (competing renderings of the same thing) or multipart/related (a part and its embedded resources). Start here, then AppendPart a body and AppendPartFromFile the attachments.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_BodyPart

li_Success = 0

//  Demonstrates the Mime.NewMultipartMixed method, which initializes the object as an empty
//  multipart/mixed entity, clearing any existing headers, body, and child parts.  It takes no
//  arguments.

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

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

//  Append child parts.  multipart/mixed is the container for a message body plus attachments.
loo_BodyPart = create oleobject
li_rc = loo_BodyPart.ConnectToNewObject("Chilkat.Mime")

li_Success = loo_BodyPart.SetBodyFromPlainText("See the attached report.")
if li_Success = 0 then
    Write-Debug loo_BodyPart.LastErrorText
    destroy loo_Mime
    destroy loo_BodyPart
    return
end if

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

li_Success = loo_Mime.AppendPartFromFile("qa_data/report.pdf")
if li_Success = 0 then
    Write-Debug loo_Mime.LastErrorText
    destroy loo_Mime
    destroy loo_BodyPart
    return
end if

Write-Debug "Number of parts: " + string(loo_Mime.NumParts)


destroy loo_Mime
destroy loo_BodyPart