PureBasic
PureBasic
Exclude Resources Matching a Pattern
See more MHT / HTML Email Examples
Demonstrates Mht.ExcludeImagesMatching, which adds an exclusion pattern used while gathering embeddable resources, so matching resources are omitted from the archive.
Background. Despite the method name, the test applies to embeddable resources generally, not only images. Each candidate is tested against its fully resolved reference — an absolute URL for web content, or the resolved local path for a local resource.
Chilkat PureBasic Downloads
IncludeFile "CkMht.pb"
Procedure ChilkatExample()
mht.i = CkMht::ckCreate()
If mht.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Add an exclusion pattern for embeddable resources. Each candidate resource is tested against its
; fully resolved reference (an absolute URL for web content), so resources whose reference matches
; the pattern are omitted from the archive. Here, resources ending in ".gif" are excluded.
CkMht::ckExcludeImagesMatching(mht,"*.gif")
; Create the MHT web archive without the excluded resources.
mhtText.s = CkMht::ckGetMHT(mht,"https://example-code.com/crumb/index.html")
If CkMht::ckLastMethodSuccess(mht) = 0
Debug CkMht::ckLastErrorText(mht)
CkMht::ckDispose(mht)
ProcedureReturn
EndIf
Debug mhtText
CkMht::ckDispose(mht)
ProcedureReturn
EndProcedure