Subject: How to eliminate duplicate mails
Hi,
You should keep only one post
Date
Topic
Remove duplicate mail before arrive (ellis yu)
How to ask a CRISPY question about Notes/Domino —
The CRISPY initiative - a quest for better questions
From searchdomino Another way to delete duplicate documents
This agent will delete duplicate documents with same serial number.
Create a View Duplicate | vSerial with two columns. The first column is sorted on “SerialNo”; the second is sorted by “DateCreated” (ascending order).
Code
Sub Initialize
Dim ses As New NotesSession
Dim selection As String
Dim collection As NotesDocumentCollection
Dim doc1 as Notesdocument
Dim doc2 as Notesdocument
Set G_db = ses.CurrentDatabase
Dim view As NotesView
Dim count As Integer
Set view = G_db.GetView(“vSerial”)
Set doc1 = view.getfirstdocument
While Not (doc1 Is Nothing)
Set doc2 = view.GetNextDocument(doc1)
If Not (doc2 Is Nothing) Then
If (doc1.serialNo(0) = doc2.serialNo(0)) Then
'----Mark Delete document to 1------------
doc2.Mark = “1”
Call doc2.save(true,true)
End If
End if
Set doc1 = view.GetNextDocument(doc1)
Wend
'------Delete Document
Dim dateTime As New NotesDateTime( “” )
Selection = “(Form = ““FORM_NAME”” & Mark=”“1"” )"
Set collection = G_db.Search( Selection, dateTime, 0 )
For j = 1 To collection.Count
Set doc2 = collection.GetNthDocument( j )
Call doc2.remove(True)
Next
End Sub
MEMBER FEEDBACK TO THIS TIP
First, the RemoveAll method permanently deletes all documents in a collection from a database. Defined in
NotesDocumentCollection
Syntax
Call notesDocumentCollection.RemoveAll( force )
Second, delete duplicate documents directly. Create a View Duplicate | vSerial with two columns. The first column is sorted on “SerialNo”; the second is sorted by “DateCreated” (descending order).
Option Public
Option Explicit
Sub Initialize
Dim ses As New NotesSession
Dim G_db As NotesDatabase
Dim view As NotesView
Dim doc1 As NotesDocument
Dim doc2 As NotesDocument
Set G_db = ses.CurrentDatabase
Set view = G_db.GetView(“vSerial”)
Set doc1 = view.GetFirstDocument
While Not doc1 Is Nothing
Set doc2 = view.GetNextDocument(doc1)
If Not doc2 Is Nothing Then
If (doc1.serialNo(0) = doc2.serialNo(0)) Then
Call doc1.Remove(True)
End If
End If
Set doc1 = doc2
Wend
End Sub
–Justin Y.
JYR