Sample code for 30+ languages & platforms
Xbase++

Send a POP3 RSET to Unmark Deletions

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3Reset method, which sends the POP3 RSET command to the server. Any messages marked for deletion during the current session are unmarked and remain in the mailbox, and the POP3 session stays open. This example marks a message for deletion, then clears the mark with RSET.

Background: RSET is POP3's in-session undo for deletion marks. It differs from Pop3EndSessionNoQuit, which also discards pending deletions but closes the connection. With RSET the authenticated session continues, so you can clear the marks and keep working — handy when a processing step fails partway and you want to retry without reconnecting.

Chilkat Xbase++ Downloads

Xbase++
LOCAL nSuccess
LOCAL oMailman

nSuccess := 0

//  Demonstrates the MailMan.Pop3Reset method, which sends the POP3 RSET command.  Any
//  messages marked for deletion during the current session are unmarked and remain in the
//  mailbox.  The POP3 session stays open.

oMailman := CreateObject("Chilkat.MailMan")

//  Configure the POP3 server connection.
oMailman:MailHost := "pop.example.com"
oMailman:MailPort := 995
oMailman:PopSsl := 1
oMailman:PopUsername := "user@example.com"
oMailman:PopPassword := "myPassword"

nSuccess := oMailman:Pop3BeginSession()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

//  Mark a message for deletion...
nSuccess := oMailman:DeleteByMsgnum(1)
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

//  ...then change your mind: RSET unmarks all pending deletions but keeps the session open.
nSuccess := oMailman:Pop3Reset()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

//  Ending the session now commits nothing, because the marks were cleared.
nSuccess := oMailman:Pop3EndSession()
IF (nSuccess == 0)
    ? oMailman:LastErrorText
    oMailman:destroy()
    RETURN
ENDIF

? "Pending deletions were unmarked with RSET."

oMailman:destroy()