DataFlex
DataFlex
Delete a Bundle of POP3 Messages
See more POP3 Examples
Demonstrates the Chilkat MailMan.DeleteBundle method, which deletes POP3 messages using the UIDLs stored in the X-UIDL headers of the Email objects in an EmailBundle. An email without an X-UIDL header is skipped. This example fetches all messages and deletes them.
Background:
DeleteBundle is the batch version of DeleteEmail: it marks every message in a downloaded bundle for deletion in one call. A typical "download and clear the mailbox" workflow is to fetch all messages, process them, then delete the whole bundle. Because a bundle can be filtered or built selectively, you can also delete just the subset you no longer need. The deletions commit when the POP3 session ends.Chilkat DataFlex Downloads
Use ChilkatAx-win32.pkg
Procedure Test
Boolean iSuccess
Handle hoMailman
Variant vBundle
Handle hoBundle
String sTemp1
Integer iTemp1
Move False To iSuccess
// Demonstrates the MailMan.DeleteBundle method, which deletes POP3 messages using the UIDLs
// stored in the X-UIDL headers of the Email objects in an EmailBundle. An email without an
// X-UIDL header is skipped.
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"
// Fetch all messages (headers are enough; each carries an X-UIDL header).
Get Create (RefClass(cComChilkatEmailBundle)) To hoBundle
If (Not(IsComObjectCreated(hoBundle))) Begin
Send CreateComObject of hoBundle
End
Get pvComObject of hoBundle to vBundle
Get ComFetchAll Of hoMailman True True 0 vBundle To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
// Delete every message in the bundle.
Get pvComObject of hoBundle to vBundle
Get ComDeleteBundle Of hoMailman vBundle To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
// 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.
Get ComPop3EndSession Of hoMailman To iSuccess
If (iSuccess = False) Begin
Get ComLastErrorText Of hoMailman To sTemp1
Showln sTemp1
Procedure_Return
End
Get ComMessageCount Of hoBundle To iTemp1
Showln "Deleted " iTemp1 " messages 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.
End_Procedure