Unicode C
Unicode C
Delete a Set of POP3 Messages by UIDL
See more POP3 Examples
Demonstrates the Chilkat MailMan.DeleteUidlSet method, which marks the POP3 messages whose UIDLs are listed in a StringTable for deletion. Chilkat processes the UIDL set and sends a DELE command for each located message. This example deletes two messages by UIDL.
Background: When you already know exactly which messages to remove — by their stable UIDLs —
DeleteUidlSet deletes them all in one call without first downloading them. It is the efficient counterpart to fetching-then-deleting: for example, after processing messages elsewhere, hand back just their UIDLs to clear them. The deletions are committed when the POP3 session ends (unless ImmediateDelete is set).Chilkat Unicode C Downloads
#include <C_CkMailManW.h>
#include <C_CkStringTableW.h>
void ChilkatSample(void)
{
BOOL success;
HCkMailManW mailman;
HCkStringTableW uidls;
success = FALSE;
// Demonstrates the MailMan.DeleteUidlSet method, which marks the POP3 messages whose UIDLs
// are listed in a StringTable for deletion. Chilkat sends DELE for each located message.
mailman = CkMailManW_Create();
// Configure the POP3 server connection.
CkMailManW_putMailHost(mailman,L"pop.example.com");
CkMailManW_putMailPort(mailman,995);
CkMailManW_putPopSsl(mailman,TRUE);
CkMailManW_putPopUsername(mailman,L"user@example.com");
CkMailManW_putPopPassword(mailman,L"myPassword");
// Build the set of UIDLs to delete.
uidls = CkStringTableW_Create();
CkStringTableW_Append(uidls,L"0000000123abcdef");
CkStringTableW_Append(uidls,L"0000000124abcdef");
// Mark the messages for deletion.
success = CkMailManW_DeleteUidlSet(mailman,uidls);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
CkStringTableW_Dispose(uidls);
return;
}
// Unless the ImmediateDelete property is set to TRUE, the messages are only marked for
// deletion. End the POP3 session (which sends the QUIT command) to commit the deletions.
success = CkMailManW_Pop3EndSession(mailman);
if (success == FALSE) {
wprintf(L"%s\n",CkMailManW_lastErrorText(mailman));
CkMailManW_Dispose(mailman);
CkStringTableW_Dispose(uidls);
return;
}
wprintf(L"Deleted the UIDL set from the POP3 server.\n");
// Note: Explicitly connecting/authenticating is optional. Chilkat MailMan automatically
// connects and authenticates -- using the property settings above -- whenever a server
// operation requires it. Calling the explicit connect/authenticate methods can still be
// helpful to determine whether a failure occurs while connecting or while authenticating.
CkMailManW_Dispose(mailman);
CkStringTableW_Dispose(uidls);
}