Sample code for 30+ languages & platforms
Lianja

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 Lianja Downloads

Lianja
llSuccess = .F.

loEmail = createobject("CkEmail")

llSuccess = loEmail.LoadEml("qa_data/eml/happyHour.eml")
if (llSuccess <> .T.) then
    ? loEmail.LastErrorText
    release loEmail
    return
endif

// Is this an HTML email?
if (loEmail.HasHtmlBody() = .T.) then

    // Unpack the HTML to files.  The image and css URLs
    // in the HTML are modified to point to the files extracted to disk.
    lcUnpackDir = "qa_output/emails"
    lcPartsSubdir = "images"
    lcHtmlFilename = "happyHour.html"
    llSuccess = loEmail.UnpackHtml(lcUnpackDir,lcHtmlFilename,lcPartsSubdir)
    if (llSuccess <> .T.) then
        ? loEmail.LastErrorText
        release loEmail
        return
    endif

    ? "Success."
endif



release loEmail