PowerBuilder
PowerBuilder
Append a Part to a Multipart MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.AppendPart method, which appends a copy of another Mime as the last direct child. The only argument is the source Mime. Chilkat copies it, so later changes to the source do not affect the appended part.
Background: This is the general way to build up a multipart entity from parts you construct yourself — a text body, an HTML body, a nested multipart. Because it appends a copy, you can reuse and modify the source object afterward, or append it more than once, without surprises. For attaching a file directly,
AppendPartFromFile is more convenient.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_Part
li_Success = 0
// Demonstrates the Mime.AppendPart method, which appends a copy of another Mime as the last direct
// child. The only argument is the Mime to append. Chilkat copies it, so later changes to the
// source do not affect the appended part.
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
// Build a part and append a copy of it.
loo_Part = create oleobject
li_rc = loo_Part.ConnectToNewObject("Chilkat.Mime")
li_Success = loo_Part.SetBodyFromPlainText("This is an appended 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 "Number of parts: " + string(loo_Mime.NumParts)
destroy loo_Mime
destroy loo_Part