Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman

li_Success = 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.

loo_Mailman = create oleobject
li_rc = loo_Mailman.ConnectToNewObject("Chilkat.MailMan")
if li_rc < 0 then
    destroy loo_Mailman
    MessageBox("Error","Connecting to COM object failed")
    return
end if

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

li_Success = loo_Mailman.Pop3BeginSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

//  Mark a message for deletion...
li_Success = loo_Mailman.DeleteByMsgnum(1)
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

//  ...then change your mind: RSET unmarks all pending deletions but keeps the session open.
li_Success = loo_Mailman.Pop3Reset()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

//  Ending the session now commits nothing, because the marks were cleared.
li_Success = loo_Mailman.Pop3EndSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

Write-Debug "Pending deletions were unmarked with RSET."


destroy loo_Mailman