Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component


Index of Chilkat Blog Posts

November 13, 2007

Deleting Email Older than N Days from POP3 Mailbox

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


Privacy Statement. Copyright 2000-2011 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, Windows 7, and Windows 95/98/NT4.