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 first published in March 2001

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:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.