Sample code for 30+ languages & platforms
DataFlex

Download POP3 Email to MIME

Download the email from a POP3 mailbox directly into MIME, without parsing into email objects.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    Variant vStUidls
    Handle hoStUidls
    Variant vBdMime
    Handle hoBdMime
    Handle hoEmail
    Integer iCount
    Integer i
    String sTemp1

    Move False To iSuccess

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

    // The mailman object is used for receiving (POP3) 
    // and sending (SMTP) email.
    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    // Set the POP3 server's hostname
    Set ComMailHost Of hoMailman To "pop.example.com"

    // Set the POP3 login/password.
    Set ComPopUsername Of hoMailman To "myLogin"
    Set ComPopPassword Of hoMailman To "myPassword"

    // First, get the complete set of UIDLs for the email in the POP3 mailbox:
    Get Create (RefClass(cComChilkatStringTable)) To hoStUidls
    If (Not(IsComObjectCreated(hoStUidls))) Begin
        Send CreateComObject of hoStUidls
    End
    Get pvComObject of hoStUidls to vStUidls
    Get ComFetchUidls Of hoMailman vStUidls To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    // Download each email as MIME.
    // If desired, the MIME can be loaded into an email object.
    Get Create (RefClass(cComChilkatBinData)) To hoBdMime
    If (Not(IsComObjectCreated(hoBdMime))) Begin
        Send CreateComObject of hoBdMime
    End
    Get Create (RefClass(cComChilkatEmail)) To hoEmail
    If (Not(IsComObjectCreated(hoEmail))) Begin
        Send CreateComObject of hoEmail
    End

    Get ComCount Of hoStUidls To iCount
    Move 0 To i
    While (i < iCount)
        Get ComStringAt Of hoStUidls i To sTemp1
        Get pvComObject of hoBdMime to vBdMime
        Get ComFetchMimeBd Of hoMailman sTemp1 vBdMime To iSuccess
        If (iSuccess = False) Begin
            Get ComLastErrorText Of hoMailman To sTemp1
            Showln sTemp1
            Procedure_Return
        End

        Get pvComObject of hoBdMime to vBdMime
        Get ComSetFromMimeBd Of hoEmail vBdMime To iSuccess
        Get ComFrom Of hoEmail To sTemp1
        Showln "From: " sTemp1
        Get ComSubject Of hoEmail To sTemp1
        Showln "Subject: " sTemp1

        Move (i + 1) To i
    Loop



End_Procedure