This VB6 example demonstrates how to delete email older than N days old from a POP3 mailbox. The same technique can be used in all programming languages supported by Chilkat: C#, VB.NET, C++, ASP, FoxPro, Delphi, Ruby, Perl, Python, Java, etc.
Assuming you’ve downloaded email into a bundle object, you would iterate over the bundle checking each email to see if it’s older than N days old. The email.LocalDate property provides the date/time. The coding for dates depends on the programming language, therefore this example cannot be automatically provided in all languages at once.
Each email to be deleted is added to a Chilkat string array object, and then the emails are delete via a single call to DeleteMultiple:
Dim bundle As ChilkatEmailBundle2
...
' Assume you've downloaded email into the bundle...
Dim toBeDeleted As New CkStringArray
Dim i As Long
Dim email As ChilkatEmail2
Dim eDate As Date
For i = 0 To bundle.MessageCount - 1
Set email = bundle.GetEmail(i)
eDate = email.LocalDate
' If older than 4 days, add the UIDL to the list to be deleted.
If (eDate < (Now - 4)) Then
toBeDeleted.Append email.uidl
End If
Next
If (toBeDeleted.Count > 0) Then
success = mailman.DeleteMultiple(toBeDeleted)
If (success = 0) Then
MsgBox mailman.LastErrorText
End If
End If