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

Export HTML with related images embedded as data URLs

See more Email Object Examples

Read inline-image.eml and produce a single UTF-8 HTML file with its related images embedded. This is useful for a self-contained preview. Treat HTML from received mail as untrusted when displaying it.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoEmail
    Variant vHtml
    Handle hoHtml
    String sTemp1
    Boolean bTemp1

    Move False To iSuccess

    //  Assumes Chilkat is unlocked. See Global Unlock Sample.

    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End
    Get ComLoadEml Of hoEmail "inline-image.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComHasHtmlBody Of hoEmail To bTemp1
    If (bTemp1 <> True) Begin
        Showln "This message has no HTML body."
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatStringBuilder)) To hoHtml
    If (Not(IsComObjectCreated(hoHtml))) Begin
        Send CreateComObject of hoHtml
    End
    Get pvComObject of hoHtml to vHtml
    Get ComGetHtmlBodySb Of hoEmail True vHtml To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComWriteFile Of hoHtml "preview.html" "utf-8" False To iSuccess
    If (iSuccess <> True) Begin
        Showln "Failed: html.WriteFile."
        Procedure_Return
    End

    Showln "Saved preview.html."


End_Procedure