PowerBuilder
PowerBuilder
End a POP3 Session Without Committing Deletions
See more POP3 Examples
Demonstrates the Chilkat MailMan.Pop3EndSessionNoQuit method, which closes the POP3 connection without sending the QUIT command. Pending deletion marks are not committed — messages marked with DELE during the session remain in the mailbox. This example marks a message for deletion and then abandons the session so the deletion does not take effect.
Background: POP3's deferred-deletion model effectively gives you a transaction: marks made with
DELE are only applied when the session ends with QUIT. Ending without QUIT is therefore a rollback — useful if an error occurs mid-processing and you'd rather leave the mailbox untouched than risk deleting messages you failed to handle. Use Pop3EndSession when you do want the deletions committed.Chilkat PowerBuilder Downloads
integer li_rc
integer li_Success
oleobject loo_Mailman
li_Success = 0
// Demonstrates the MailMan.Pop3EndSessionNoQuit method, which closes the POP3 connection
// WITHOUT sending the QUIT command. Pending deletion marks are not committed -- messages
// marked with DELE during the session remain in the mailbox.
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
// ...but end the session without QUIT, so the deletion is NOT committed and the message
// remains in the mailbox.
li_Success = loo_Mailman.Pop3EndSessionNoQuit()
if li_Success = 0 then
Write-Debug loo_Mailman.LastErrorText
destroy loo_Mailman
return
end if
Write-Debug "Session closed without committing the pending deletion."
destroy loo_Mailman