Delphi DLL
Delphi DLL
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 Delphi DLL Downloads
var
success: Boolean;
mailman: HCkMailMan;
begin
success := False;
// 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.
mailman := CkMailMan_Create();
// Configure the POP3 server connection.
CkMailMan_putMailHost(mailman,'pop.example.com');
CkMailMan_putMailPort(mailman,995);
CkMailMan_putPopSsl(mailman,True);
CkMailMan_putPopUsername(mailman,'user@example.com');
CkMailMan_putPopPassword(mailman,'myPassword');
success := CkMailMan_Pop3BeginSession(mailman);
if (success = False) then
begin
Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
Exit;
end;
// Mark a message for deletion...
success := CkMailMan_DeleteByMsgnum(mailman,1);
if (success = False) then
begin
Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
Exit;
end;
// ...but end the session without QUIT, so the deletion is NOT committed and the message
// remains in the mailbox.
success := CkMailMan_Pop3EndSessionNoQuit(mailman);
if (success = False) then
begin
Memo1.Lines.Add(CkMailMan__lastErrorText(mailman));
Exit;
end;
Memo1.Lines.Add('Session closed without committing the pending deletion.');
CkMailMan_Dispose(mailman);