DataFlex
DataFlex
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 DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
String sTemp1
Move False To iSuccess
// 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.
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"
Get ComPop3BeginSession Of hoMailman To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
// Mark a message for deletion...
Get ComDeleteByMsgnum Of hoMailman 1 To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
// ...but end the session without QUIT, so the deletion is NOT committed and the message
// remains in the mailbox.
Get ComPop3EndSessionNoQuit Of hoMailman To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Showln "Session closed without committing the pending deletion."
End_Procedure