We’re testing new anti-spam software that delivers any spam into a standard, central R6 mail db. We want an agent that will run on schedule (perhaps once a day) and E mail the user a list of any messages trapped on their behalf. In the script below ‘ARPQuar’ is the view that has ‘SendTo’ as the first column. Currently there are 10 messages in the database for 4 users. Eventually it should send to ‘People’ rather than have me hard-coded in. During testing and debug it loops through the ‘Forall’ 4 times but each time attatches all 10 messages to the newsletter rather than just the ones relevant to the user.
I’ve tried oodles of variations but can’t see where I’m going wrong. Can anyone advise?
Sub Initialize
Dim MyUsers As Variant
MyUsers = Evaluate({@unique(@DbColumn("";"":"";"ARPQuar";1))}, evaldoc)
Forall People In MyUsers
Dim session As New NotesSession
Dim db As NotesDatabase
Dim collection As NotesDocumentCollection
Dim newsletter As NotesNewsletter
Dim doc As NotesDocument
Set db = session.CurrentDatabase
Set collection = db.Search("@Contains(SendTo;People)", Nothing, 0)
If ( collection.Count > 0 ) Then
Set newsletter = New NotesNewsletter( collection )
newsletter.DoSubject=True
newsletter.SubjectItemName="From"
Set doc = newsletter.FormatMsgWithDoclinks( db )
doc.Form = "Memo"
doc.Subject = "Spam Alert"
Call doc.Send( False, "Andy R Poulton" )
End If
End Forall
End Sub