Tcl Requires Chilkat v11.0.0+
Tcl
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 Tcl Downloads
load ./chilkat.dll
set success 0
# Assumes Chilkat is unlocked. See Global Unlock Sample.
set email [new_CkEmail]
CkEmail_put_From $email "Workshop team <events@example.com>"
set success [CkEmail_AddTo $email "Alex Rivera" "alex@example.net"]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $email
exit
}
CkEmail_put_Subject $email "Workshop registration"
CkEmail_SetHtmlBody $email "<html><body><p>Registration confirmed.</p><img src=\"data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///ywAAAAAAQABAAACAUwAOw==\" alt=\"Mark\"></body></html>"
set success [CkEmail_ConvertInlineImages $email]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $email
exit
}
puts "Related images: [CkEmail_get_NumRelatedItems $email]"
puts [CkEmail_getHtmlBody $email]
set success [CkEmail_SaveEml $email "related-images.eml"]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $email
exit
}
puts "Saved related-images.eml."
delete_CkEmail $email