Sample code for 30+ languages & platforms
PowerBuilder

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 PowerBuilder Downloads

PowerBuilder
integer li_rc
integer li_Success
oleobject loo_Mailman
oleobject loo_Uidls

li_Success = 0

//  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.

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"

//  Build the set of UIDLs to delete.
loo_Uidls = create oleobject
li_rc = loo_Uidls.ConnectToNewObject("Chilkat.StringTable")

loo_Uidls.Append("0000000123abcdef")
loo_Uidls.Append("0000000124abcdef")

//  Mark the messages for deletion.

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

//  Unless the ImmediateDelete property is set to 1, the messages are only marked for
//  deletion.  End the POP3 session (which sends the QUIT command) to commit the deletions.
li_Success = loo_Mailman.Pop3EndSession()
if li_Success = 0 then
    Write-Debug loo_Mailman.LastErrorText
    destroy loo_Mailman
    destroy loo_Uidls
    return
end if

Write-Debug "Deleted the UIDL set from the POP3 server."

//  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.


destroy loo_Mailman
destroy loo_Uidls