(PureBasic) 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.
IncludeFile "CkEmail.pb"
Procedure ChilkatExample()
email.i = CkEmail::ckCreate()
If email.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
success.i
success = CkEmail::ckLoadEml(email,"qa_data/eml/happyHour.eml")
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
; Is this an HTML email?
If CkEmail::ckHasHtmlBody(email) = 1
; Unpack the HTML to files. The image and css URLs
; in the HTML are modified to point to the files extracted to disk.
unpackDir.s = "qa_output/emails"
partsSubdir.s = "images"
htmlFilename.s = "happyHour.html"
success = CkEmail::ckUnpackHtml(email,unpackDir,htmlFilename,partsSubdir)
If success <> 1
Debug CkEmail::ckLastErrorText(email)
CkEmail::ckDispose(email)
ProcedureReturn
EndIf
Debug "Success."
EndIf
CkEmail::ckDispose(email)
ProcedureReturn
EndProcedure
|