Auto E-Mail Housekeeping Agent

Some users just constantly ignore the corporate IT notice to housekeep their mail databases. This is giving administrators headaches.

This agent can be incorporated into the mail template and distributed to all mail databases to help housekeeping their e-mails daily.

Just plucked in the mail database size quota value into the 'IsOverQuota' function and then specify the age (number of days) in the 'RemoveMails' subroutine and finally schedule the agent to run daily at an off peak hours.

Don't forgot to make an official announcement and jot it down black and white, else IT will have another headache again!

Dim session As NotesSession
Dim db As NotesDatabase

Sub Initialize
Set session = New NotesSession
Set db = session.CurrentDatabase
'If mail box is over 50 MB, remove 120 days old mails.
If IsOverQuota (50) Then
Call RemoveMails (120)
End If
End Sub

Function IsOverQuota (iQuota As Integer)
'iQuota is in Megabytes
Dim quota As Long, CurrSize As Double, MaxSize As Double
'Converts DB size to Megabytes
CurrSize = Round (db.Size/1000000, 2)
MaxSize = Cdbl(iQuota) ' Megabytes
If CurrSize> MaxSize Then
IsOverQuota = True
IsOverQuota = False
End If
End Function

Sub RemoveMails (iMailAge As Integer)
'iMage Age is in number of days
Dim strSearchFomula As String
Dim docCollection As NotesDocumentCollection
Dim strMailAge As String
'Convert the number days to string as Notes Formulae is formatted as string
strMailAge = Cstr(iMailAge)
strSearchFormula = "DeliveredDate < @Adjust(@Today;0;0;-" + strMailAge + ";0;0;0) | PostedDate < @Adjust(@Today;0;0;-" + strMailAge + ";0;0;0)| @Created < @Adjust(@Today;0;0;-" + strMailAge + ";0;0;0)"
Set docCollection=db.Search(strSearchFormula, Nothing,0)
'Remove the old documents
If docCollection.Count <> 0 Then
Call docCollection.RemoveAll(True)
End If
End Sub

This was last published in March 2001

Dig Deeper on Domino Resources - Part 2

Start the conversation

Send me notifications when other members comment.

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

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...