Sample code for 30+ languages & platforms
Xbase++ Requires Chilkat v11.0.0+

Extract Files from MIME

See more MIME Examples

Extract files from a MIME message.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMime
LOCAL oSt
LOCAL n
LOCAL i

nSuccess := 0

//  This example requires the Chilkat API to have been previously unlocked.
//  See Global Unlock Sample for sample code.

oMime := CreateObject("Chilkat.Mime")

//  Load a MIME document from a file:
//  (.mht and .eml files contain MIME).
nSuccess := oMime:LoadMimeFile("mst.mht")
IF (nSuccess == 0)
    ? oMime:LastErrorText
    oMime:destroy()
    RETURN
ENDIF

oSt := CreateObject("Chilkat.StringTable")
nSuccess := oMime:PartsToFiles("/temp/mimeParts", oSt)
IF (nSuccess == 0)
    ? oMime:LastErrorText
    oMime:destroy()
    oSt:destroy()
    RETURN
ENDIF

n := oSt:Count

//  Display the paths of the files created:
i := 0
DO WHILE i < n
    ? oSt:StringAt(i)
    i := i + 1
ENDDO

oMime:destroy()
oSt:destroy()