Ask the Expert

Purging e-mail folders based on date

As a K-12 school district with 800 staff members, each with Lotus Notes e-mail accounts, getting users to clean up their basic folders (the inbox and sent folders) is difficult. During this summer, we want to automatically purge both folders for each user based upon a given date. What would be the best way to accomplish a purge using a selected date for both folders -- using the "Remove" option on the Sent folder items?
I know of a few organizations who have implemented this type of document "purge" in order to have documents located in either the sent folder or inbox to be automatically deleted after a given period of time.

I understand the logic behind it -- a document, for example, in the Inbox after a month is "stale." So those organizations make users who want to keep e-mail move if from the inbox/sent folders within a certain timeframe and place it in another "personal" folder, otherwise the document is deleted.

Not that I agree with the logic -- I just understand it.

The easiest way to accomplish your task is to create a scheduled agent, which would cycle through all the documents located in the folders you have specified, and delete any documents that were created before your selected date.

Be aware the "Remove" method of LotusScript will delete the document (or place it in the trash if "soft deletions" are turned on). If you use the "RemoveFromFolder" method, the document will be removed from the folder, but will still be available in the "All Documents" and "Mail Threads" views.

Your agent would look something like this...

        Dim db As New NotesDatabase( "yourserver", "mail\themail.nsf" ) 
        Dim view As NotesView 
        Dim doc As NotesDocument 
        Dim docr As NotesDocument 'Temporary placeholder to delete document 
        Set view = db.GetView( "($Inbox)" ) 
        Set doc = view.GetFirstDocument 
        While Not(doc Is Nothing) 
                Set docr = doc 
                Set doc = view.GetNextDocument(doc) 
                If docr.Created < Datenumber( 2005, 7, 4 ) Then 
                        Call docr.Remove 
                End If 
Substitute Call docr.Remove, with Call doc.RemoveFromFolder( "($Inbox)") if your intention is just to "clean up" the inbox/sent folders, rather than deleting those e-mail messages.

This was first published in June 2005

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to: