Sample code for 30+ languages & platforms
DataFlex

Explicitly Begin a POP3 Session

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3BeginSession method, which explicitly begins a POP3 session by connecting to the POP3 server and authenticating using the current POP3 property settings. Calling it is optional. This example begins a session, performs a mailbox operation, and ends the session.

Background: Pop3BeginSession combines connecting and authenticating into one call. Chilkat does this automatically when a mailbox operation needs it, so the value of calling it explicitly is control: you open one session, perform several operations against it, and close it with Pop3EndSession — avoiding repeated connect/authenticate round trips and keeping deletion marks within a single, well-defined session.

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    String sTemp1
    Integer iTemp1

    Move False To iSuccess

    //  Demonstrates the MailMan.Pop3BeginSession method, which explicitly begins a POP3 session
    //  by connecting to the POP3 server and authenticating using the current POP3 property
    //  settings.

    Get Create (RefClass(cComChilkatMailMan)) To hoMailman
    If (Not(IsComObjectCreated(hoMailman))) Begin
        Send CreateComObject of hoMailman
    End

    //  Configure the POP3 server connection.
    Set ComMailHost Of hoMailman To "pop.example.com"
    Set ComMailPort Of hoMailman To 995
    Set ComPopSsl Of hoMailman To True
    Set ComPopUsername Of hoMailman To "user@example.com"
    Set ComPopPassword Of hoMailman To "myPassword"

    //  Explicitly begin the POP3 session (connect + authenticate).

    Get ComPop3BeginSession Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Perform one or more mailbox operations within this single session.
    Get ComGetMailboxCount Of hoMailman To iTemp1
    Showln "Mailbox count: " iTemp1

    //  End the session when finished.
    Get ComPop3EndSession Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "POP3 session completed."


End_Procedure