Sample code for 30+ languages & platforms
PowerBuilder Requires Chilkat v11.0.0+

Convert image data URLs to related MIME parts

See more Email Object Examples

Start with HTML that contains image bytes in a data URL. Convert it to conventional CID references and inspect the resulting related-item count before saving.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
long li_Success
oleobject loo_Email

li_Success = 0

//  Assumes Chilkat is unlocked. See Global Unlock Sample.

loo_Email = create oleobject
li_rc = loo_Email.ConnectToNewObject("Chilkat.Email")
if li_rc < 0 then
    destroy loo_Email
    MessageBox("Error","Connecting to COM object failed")
    return
end if
loo_Email.From = "Workshop team <events@example.com>"
li_Success = loo_Email.AddTo("Alex Rivera","alex@example.net")
if li_Success <> 1 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

loo_Email.Subject = "Workshop registration"
loo_Email.SetHtmlBody("<html><body><p>Registration confirmed.</p><img src=~"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==~" alt=~"Mark~"></body></html>")
li_Success = loo_Email.ConvertInlineImages()
if li_Success <> 1 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

Write-Debug "Related images: " + string(loo_Email.NumRelatedItems)
Write-Debug loo_Email.GetHtmlBody()

li_Success = loo_Email.SaveEml("related-images.eml")
if li_Success <> 1 then
    Write-Debug loo_Email.LastErrorText
    destroy loo_Email
    return
end if

Write-Debug "Saved related-images.eml."


destroy loo_Email