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

Export HTML with related images embedded as data URLs

See more Email Object Examples

Read inline-image.eml and produce a single UTF-8 HTML file with its related images embedded. This is useful for a self-contained preview. Treat HTML from received mail as untrusted when displaying it.

Chilkat B4X Downloads

B4X
Dim success As Boolean = False

'  Assumes Chilkat is unlocked. See Global Unlock Sample.

Dim email As ChilkatEmail
email.Initialize
success = email.LoadEml("inline-image.eml")
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

If email.HasHtmlBody <> True Then
    Log("This message has no HTML body.")
    Return
End If

Dim html As ChilkatStringBuilder
html.Initialize
success = email.GetHtmlBodySb(True, html)
If success <> True Then
    Log(email.LastErrorText)
    Return
End If

success = html.WriteFile("preview.html", "utf-8", False)
If success <> True Then
    Log("Failed: html.WriteFile.")
    Return
End If

Log("Saved preview.html.")