PowerBuilder
PowerBuilder
Create a multipart/related MIME Entity
See more MIME Examples
Demonstrates the Chilkat Mime.NewMultipartRelated method, which initializes the object as an empty multipart/related entity. It takes no arguments; the primary part and its related resources 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/related ties a primary part to the resources it references — most commonly an HTML body and the inline images it embeds via cid: references. Unlike a plain attachment, a related image is displayed within the message rather than listed separately. The HTML part comes first, followed by each referenced resource with a matching Content-ID.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mime
oleobject loo_HtmlPart
li_Success = 0
// Demonstrates the Mime.NewMultipartRelated method, which initializes the object as an empty
// multipart/related entity, clearing any existing content. 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.NewMultipartRelated()
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
return
end if
// multipart/related groups a primary part with the resources it references, such as an HTML body
// and the inline images it displays.
loo_HtmlPart = create oleobject
li_rc = loo_HtmlPart.ConnectToNewObject("Chilkat.Mime")
li_Success = loo_HtmlPart.SetBodyFromHtml("<html><body><img src=~"cid:logo~"></body></html>")
if li_Success = 0 then
Write-Debug loo_HtmlPart.LastErrorText
destroy loo_Mime
destroy loo_HtmlPart
return
end if
li_Success = loo_Mime.AppendPart(loo_HtmlPart)
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_HtmlPart
return
end if
li_Success = loo_Mime.AppendPartFromFile("qa_data/logo.png")
if li_Success = 0 then
Write-Debug loo_Mime.LastErrorText
destroy loo_Mime
destroy loo_HtmlPart
return
end if
Write-Debug "Number of parts: " + string(loo_Mime.NumParts)
destroy loo_Mime
destroy loo_HtmlPart