AutoIt
AutoIt
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 AutoIt Downloads
Local $bSuccess = False
; 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.
$oMailman = ObjCreate("Chilkat.MailMan")
; Configure the POP3 server connection.
$oMailman.MailHost = "pop.example.com"
$oMailman.MailPort = 995
$oMailman.PopSsl = True
$oMailman.PopUsername = "user@example.com"
$oMailman.PopPassword = "myPassword"
; Fetch all messages (headers are enough; each carries an X-UIDL header).
$oBundle = ObjCreate("Chilkat.EmailBundle")
$bSuccess = $oMailman.FetchAll(True,True,0,$oBundle)
If ($bSuccess = False) Then
ConsoleWrite($oMailman.LastErrorText & @CRLF)
Exit
EndIf
; Delete every message in the bundle.
$bSuccess = $oMailman.DeleteBundle($oBundle)
If ($bSuccess = False) Then
ConsoleWrite($oMailman.LastErrorText & @CRLF)
Exit
EndIf
; 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.
$bSuccess = $oMailman.Pop3EndSession()
If ($bSuccess = False) Then
ConsoleWrite($oMailman.LastErrorText & @CRLF)
Exit
EndIf
ConsoleWrite("Deleted " & $oBundle.MessageCount & " messages from the POP3 server." & @CRLF)
; 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.