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

Tcl

load ./chilkat.dll

set success 0

#  Assumes Chilkat is unlocked. See Global Unlock Sample.

set email [new_CkEmail]

set success [CkEmail_LoadEml $email "inline-image.eml"]
if {$success != 1} then {
    puts [CkEmail_lastErrorText $email]
    delete_CkEmail $email
    exit
}

if {[CkEmail_HasHtmlBody $email] != 1} then {
    puts "This message has no HTML body."
    delete_CkEmail $email
    exit
}

set html [new_CkStringBuilder]

set success [CkEmail_GetHtmlBodySb $email 1 $html]
if {$success != 1} then {
    puts [CkEmail_lastErrorText $email]
    delete_CkEmail $email
    delete_CkStringBuilder $html
    exit
}

set success [CkStringBuilder_WriteFile $html "preview.html" "utf-8" 0]
if {$success != 1} then {
    puts "Failed: html.WriteFile."
    delete_CkEmail $email
    delete_CkStringBuilder $html
    exit
}

puts "Saved preview.html."

delete_CkEmail $email
delete_CkStringBuilder $html