(Tcl) Extract Files from MIME
Extract files from a MIME message.
load ./chilkat.dll
# This example requires the Chilkat API to have been previously unlocked.
# See Global Unlock Sample for sample code.
set mime [new_CkMime]
# Load a MIME document from a file:
# (.mht and .eml files contain MIME).
set success [CkMime_LoadMimeFile $mime "mst.mht"]
if {$success == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
exit
}
# sa is a CkStringArray
set sa [CkMime_ExtractPartsToFiles $mime "/temp/mimeParts"]
if {[CkMime_get_LastMethodSuccess $mime] == 0} then {
puts [CkMime_lastErrorText $mime]
delete_CkMime $mime
exit
}
set i 0
set n [CkStringArray_get_Count $sa]
# Display the filepaths of the files created:
while {$i < $n} {
puts [CkStringArray_getString $sa $i]
set i [expr $i + 1]
}
delete_CkStringArray $sa
delete_CkMime $mime
|