Sample code for 30+ languages & platforms
DataFlex

Delete a Set of POP3 Messages by UIDL

See more POP3 Examples

Demonstrates the Chilkat MailMan.DeleteUidlSet method, which marks the POP3 messages whose UIDLs are listed in a StringTable for deletion. Chilkat processes the UIDL set and sends a DELE command for each located message. This example deletes two messages by UIDL.

Background: When you already know exactly which messages to remove — by their stable UIDLs — DeleteUidlSet deletes them all in one call without first downloading them. It is the efficient counterpart to fetching-then-deleting: for example, after processing messages elsewhere, hand back just their UIDLs to clear them. The deletions are committed when the POP3 session ends (unless ImmediateDelete is set).

Chilkat DataFlex Downloads

DataFlex
Use ChilkatAx-win32.pkg

Procedure Test
    Boolean iSuccess
    Handle hoMailman
    Variant vUidls
    Handle hoUidls
    String sTemp1

    Move False To iSuccess

    //  Demonstrates the MailMan.DeleteUidlSet method, which marks the POP3 messages whose UIDLs
    //  are listed in a StringTable for deletion.  Chilkat sends DELE for each located message.

    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"

    //  Build the set of UIDLs to delete.
    Get Create (RefClass(cComChilkatStringTable)) To hoUidls
    If (Not(IsComObjectCreated(hoUidls))) Begin
        Send CreateComObject of hoUidls
    End
    Get ComAppend Of hoUidls "0000000123abcdef" To iSuccess
    Get ComAppend Of hoUidls "0000000124abcdef" To iSuccess

    //  Mark the messages for deletion.

    Get pvComObject of hoUidls to vUidls
    Get ComDeleteUidlSet Of hoMailman vUidls To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    //  Unless the ImmediateDelete property is set to True, the messages are only marked for
    //  deletion.  End the POP3 session (which sends the QUIT command) to commit the deletions.
    Get ComPop3EndSession Of hoMailman To iSuccess
    If (iSuccess = False) Begin
        Get ComLastErrorText Of hoMailman To sTemp1
        Showln sTemp1
        Procedure_Return
    End

    Showln "Deleted the UIDL set from the POP3 server."

    //  Note: Explicitly connecting/authenticating is optional.  Chilkat MailMan automatically
    //  connects and authenticates -- using the property settings above -- whenever a server
    //  operation requires it.  Calling the explicit connect/authenticate methods can still be
    //  helpful to determine whether a failure occurs while connecting or while authenticating.


End_Procedure