Sample code for 30+ languages & platforms
Xbase++

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.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oEmail
LOCAL cUnpackDir
LOCAL cPartsSubdir
LOCAL cHtmlFilename

nSuccess := 0

oEmail := CreateObject("Chilkat.Email")

nSuccess := oEmail:LoadEml("qa_data/eml/happyHour.eml")
IF (nSuccess != 1)
    ? oEmail:LastErrorText
    oEmail:destroy()
    RETURN
ENDIF

//  Is this an HTML email?
IF (oEmail:HasHtmlBody() == 1)

    //  Unpack the HTML to files.  The image and css URLs
    //  in the HTML are modified to point to the files extracted to disk.
    cUnpackDir := "qa_output/emails"
    cPartsSubdir := "images"
    cHtmlFilename := "happyHour.html"
    nSuccess := oEmail:UnpackHtml(cUnpackDir, cHtmlFilename, cPartsSubdir)
    IF (nSuccess != 1)
        ? oEmail:LastErrorText
        oEmail:destroy()
        RETURN
    ENDIF

    ? "Success."
ENDIF

oEmail:destroy()