(Tcl) Unpack HTML Email to Files
Unpacks an HTML email into an HTML file and related files (images and style sheets). The links within the HTML are updated to point to the files unpacked and saved to disk.
load ./chilkat.dll
set email [new_CkEmail]
set success [CkEmail_LoadEml $email "qa_data/eml/happyHour.eml"]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $email
exit
}
# Is this an HTML email?
if {[CkEmail_HasHtmlBody $email] == 1} then {
# Unpack the HTML to files. The image and css URLs
# in the HTML are modified to point to the files extracted to disk.
set unpackDir "qa_output/emails"
set partsSubdir "images"
set htmlFilename "happyHour.html"
set success [CkEmail_UnpackHtml $email $unpackDir $htmlFilename $partsSubdir]
if {$success != 1} then {
puts [CkEmail_lastErrorText $email]
delete_CkEmail $email
exit
}
puts "Success."
}
delete_CkEmail $email
|