Delete particular mail from all mail files of the users selected from Domino Directory

Some users make the mistake of sending messages that should not go to some people and  not save the sent message which complicates the use of the recall. I found this documentation in a TechNote that can help solve the problem

Create one LotusScript agent in Domino Directory with all default properties such as it will run on event and target documents are all selected documents.  Paste below code in the agent.

Save the agent and open domino directory from Notes Client.  Select the person documents for which users the mail has to be deleted from their mail file.  And then select Tools--><>.

Once successful, the confirmation message will be popped up.  Please ensure that the id by which agent will be signed should be present in mail file of user's ACL.

Change subject text in below code.

Option Public
Option Declare

%Include "lsconst.lss"
Sub Initialize
        Dim s As New NotesSession
        Dim db As NotesDatabase
        Dim view As NotesView
        Dim dc As NotesDocumentCollection
        Dim doc As NotesDocument
        Dim db1 As NotesDatabase        
        Dim noofrec As Integer        
        Dim mailserv As String
        Dim mailfl As String
        noofrec =0
        Dim doccol As NotesDocumentCollection
        Dim searchstring As String
        Dim doc1 As NotesDocument
        Dim doc2 As NotesDocument
        Set db=s.Currentdatabase
        Set view=db.Getview("($Users)")
        Set dc=db.Unprocesseddocuments
        Set doc=dc.GetFirstDocument
        searchstring "hi swati how r u"  'change this text
        While Not doc Is Nothing
                mailserv = doc.GetItemValue("MailServer")(0)
                mailfl = doc.GetItemValue ("MailFile")(0)
                Set db1 = s.GetDatabase(mailserv,mailfl)
                If Not db1 Is Nothing Then
                        If db1.IsOpen Then
                                Set doccol = db1.FTSearch(searchstring,0)
                                Set doc1 = doccol.GetFirstDocument
                                While Not doc1 Is Nothing
                                        Set doc2 = doccol.GetNextDocument(doc1)
                                        Call doc1.RemovePermanently(True)  
                                        Set doc1 = doc2
                                noofrec = noofrec + 1
                        End If
                End If
                Set doc = dc.Getnextdocument(doc)
        If noofrec <> 0 Then
                MsgBox noofrec & " record(s) successfully updated " , MB_OK, "Lotus Notes"
        End If
        End sub