Sample code for 30+ languages & platforms
B4X 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 B4X Downloads

B4X
Dim success As Boolean = False

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As ChilkatEmail
email.Initialize
email.From = "Workshop team <events@example.com>"
success = email.AddTo("Alex Rivera", "alex@example.net")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

email.Subject = "Workshop registration"
email.SetHtmlBody("<html><body><p>Registration confirmed.</p><img src=" & Chr(34) & "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==" & Chr(34) & " alt=" & Chr(34) & "Mark" & Chr(34) & "></body></html>")
success = email.ConvertInlineImages
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

Log("Related images: " & email.NumRelatedItems)
Log(email.GetHtmlBody)

success = email.SaveEml("related-images.eml")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

Log("Saved related-images.eml.")