DataFlex
DataFlex
Unpack MHT to Files
See more MHT / HTML Email Examples
Demonstrates how to unpack a .mhtml to files. Unpacks the HTML and to a directory, and image files to a sub-directory located under the directory where the HTML file is unpacked. The image links in the HTML are updated to point to the image files.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMht
String sMhtPath
String sUnpackDir
String sHtmlFilename
String sPartsSubDir
String sTemp1
Move False To iSuccess
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
Get Create (RefClass(cComChilkatMht)) To hoMht
If (Not(IsComObjectCreated(hoMht))) Begin
Send CreateComObject of hoMht
End
// This should be an absolute or relative path to the MHT file.
// It is the MHT to be unpacked.
Move "qa_data/mht/test.mht" To sMhtPath
Move "C:/AAWorkarea/mht_unpack" To sUnpackDir
Move "test.html" To sHtmlFilename
Move "images" To sPartsSubDir
// Unpacking will create the HTML file C:/AAWorkarea/mht_unpack/test.html
// The image files are unpacked to C:/AAWorkarea/mht_unpack/images
// The unpackDir and partsSubDir are automatically created if needed.
Get ComUnpackMHT Of hoMht sMhtPath sUnpackDir sHtmlFilename sPartsSubDir To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMht To sTemp1
Showln sTemp1
Showln "Failed."
End
Else Begin
Showln "Success."
End
End_Procedure