This will block senders on a user-by-user basis rather than using the server configuration document. It consists of five parts:
1. A modified Inbox folder to include a "Block Sender" button.
2. An "Add to blocked senders" agent that will add the sender to your list.
3. A view containing all your blocked senders (giving you the ability to easily remove an entry from the list).
4. A form that contains the blocked sender entry.
5. A Before Mail Arrives agent to query each incoming mail message to see if the user is on your blocked senders list.
Inbox Folder "Block Sender(s)" button:
1. In the Inbox folder, create a new action titled "Block Sender".
2. Set it as a Simple Action, @Function Formula, Select document when run.
3. The formula is @Command([ToolsRunMacro];"(BlockSender)")
Creating the BlockSender agent:
1. Title the agent BlockSender, and set it to run Manually from Agent List. It should run on Selected Documents.
2. These are your LotusScript declarations:
Dim db As NotesDatabase
Dim doc As NotesDocument
Dim col As NotesDocumentCollection
Dim blockdoc As NotesDocument
Dim view As NotesView
Dim existBlockdoc As NotesDocument
3. This is the code for the agent itself:
Sub Initialize Dim session As New NotesSession Set db = session.CurrentDatabase Set view = db.GetView("Blocked Senders") Set col = db.unprocesseddocuments Set doc = col.GetFirstDocument
While Not doc Is Nothing Set existBlockdoc = view.GetDocumentByKey(doc.From(0))
If existBlockdoc Is Nothing Then Set blockdoc = New NotesDocument(db) blockdoc.Form = "Blocked Sender" blockdoc.BlockedSender = doc.From(0) Call blockdoc.Save(False, False) Else Msgbox (doc.From(0) +" is already in your Blocked Senders list.") End If Set doc = col.GetNextDocument(doc) Wend
If col.Count > 1 Then Msgbox "All senders have been successfully added to your Blocked Senders list
unless already added." Else Set doc = col.GetLastDocument Msgbox (doc.From(0) + " has been successfully added to your Blocked Senders
list unless already added.") End If End Sub
Creating your form for each Blocked Sender entry:
1. Create a form titled "Blocked Sender".
2. Include one field titled BlockedSender, text, editable.
Create a view for each Blocked Sender entry:
1. Create a view titled "Blocked Senders".
2. It needs a view selection formula of By Form Used->Blocked Sender.
3. It needs one column only, with the field value of BlockedSender.
4. Make sure the column is sorted!
Creating the agent to query the messages:
1. Create an agent called DeleteBlockedSenders.
2. Set the agent to run Before New Mail Arrives.
3. These are your LotusScript declarations:
Dim db As NotesDatabase Dim doc As NotesDocument Dim view As Notesview Dim blockdoc As NotesDocument
4. This is the code for the agent itself:
Sub Initialize Dim session As New NotesSession Set session = New NotesSession Set db = session.CurrentDatabase Set view = db.GetView("Blocked Senders") Set doc = session.documentcontext Set blockdoc = view.GetDocumentByKey(doc.From(0)) If blockdoc Is Nothing Then Exit Sub Else Call doc.Remove(True) End If End Sub