Sample code for 30+ languages & platforms
PowerBuilder

End a POP3 Session (Commit Deletions)

See more POP3 Examples

Demonstrates the Chilkat MailMan.Pop3EndSession method, which ends the current POP3 session by sending the QUIT command. Ending the session normally commits any messages that were marked for deletion during the session. This example begins a session and then ends it.

Background: POP3 deletion is deferred: DELE commands only mark messages during the session, and the server permanently removes them when the client sends QUIT to end the session cleanly. Pop3EndSession is that commit point. If a session is dropped without QUIT (see Pop3EndSessionNoQuit), the server rolls back the pending deletions and the messages remain.

Chilkat PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman

li_Success = 0

//  Demonstrates the MailMan.Pop3EndSession method, which ends the current POP3 session by
//  sending the QUIT command.  Ending the session normally commits any messages that were
//  marked for deletion during the session.

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"

//  Explicitly begin a POP3 session.

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

//  ... perform mailbox operations here, such as fetching or marking messages for deletion ...

//  End the POP3 session (sends QUIT), committing any pending deletions.
li_Success = loo_Mailman.Pop3EndSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    return
end if

Write-Debug "POP3 session ended."


destroy loo_Mailman