(PureBasic) Extract Files from MIME
Extract files from a MIME message.
IncludeFile "CkStringArray.pb"
IncludeFile "CkMime.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
mime.i = CkMime::ckCreate()
If mime.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
; Load a MIME document from a file:
; (.mht and .eml files contain MIME).
success.i = CkMime::ckLoadMimeFile(mime,"mst.mht")
If success = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
sa.i = CkMime::ckExtractPartsToFiles(mime,"/temp/mimeParts")
If CkMime::ckLastMethodSuccess(mime) = 0
Debug CkMime::ckLastErrorText(mime)
CkMime::ckDispose(mime)
ProcedureReturn
EndIf
i.i = 0
n.i = CkStringArray::ckCount(sa)
; Display the filepaths of the files created:
While i < n
Debug CkStringArray::ckGetString(sa,i)
i = i + 1
Wend
CkStringArray::ckDispose(sa)
CkMime::ckDispose(mime)
ProcedureReturn
EndProcedure
|