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

Pass an Email object to the MIME API

See more Email Object Examples

Serialize an Email into a fresh BinData buffer and load those bytes into Mime to inspect the tree. Keep the original file separately when byte-for-byte preservation matters, such as for DKIM verification.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoEmail
    Variant vMimeBytes
    Handle hoMimeBytes
    Handle hoMime
    String sTemp1

    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 "message.eml" To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatBinData)) To hoMimeBytes
    If (Not(IsComObjectCreated(hoMimeBytes))) Begin
        Send CreateComObject of hoMimeBytes
    End
    Get pvComObject of hoMimeBytes to vMimeBytes
    Get ComGetMimeBd Of hoEmail vMimeBytes To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoEmail To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get Create (RefClass(cComChilkatMime)) To hoMime
    If (Not(IsComObjectCreated(hoMime))) Begin
        Send CreateComObject of hoMime
    End
    Get pvComObject of hoMimeBytes to vMimeBytes
    Get ComLoadMimeBd Of hoMime vMimeBytes To iSuccess
    If (iSuccess <> True) Begin
        Get ComLastErrorText Of hoMime To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Get ComGetStructure Of hoMime "text" To sTemp1
    Showln sTemp1


End_Procedure