LotusScript code to compare number of marked messages

Tags:
Email monitoring
Lotus Notes
LotusScript
When sending email to multiple addressees and receiving answers which are again sent to many users, this creates a large amount of redundant information. Is there any LotusScript code that I could use to compare a number of marked messages with a defined "master message" (usually the newest) and remove duplicate sections in the marked (older) messages?

Answer Wiki

Thanks. We'll let you know when a new response is added.

Well that’s really two questions isn’t it? First, how to get a handle on the documents and there contents, and second, what algorythm to use to compare and trim the text?

To get a handle on the selected documents, you only have to use the database unprocessed documents collection. From an agent set to run on selected documents, this will always return the selected documents. The documentation says they are returned in random order, but actually that’s not true. They are, in fact, returned in the order they were added to the database, so you can easily grab the most recent document without any need to sort or process the list.

Then you have to look at the contents. The Body field in a Notes email is a RichText field and LotusScript only provides an easy way to get at its text contents. So if you want to be able to preservce rich text contents, your little project is quickly going to get very costly. But if you are content to trim the older messages down to archival text, you might do something like this:

Sub Initialize
Dim session As New NotesSession
Dim db As NotesDatabase
Dim Selected As NotesDocumentCollection
Dim Doc As NotesDocument
Dim Master As NotesDocument

Set db=session.CurrentDatabase ‘ Get handle to database
Set Selected=db.UnprocessedDocuments ‘ Get collection of all selected documents.

Set Master=Selected.getnthdocument(1)
Dim MasterBody As NotesRichTextItem
Dim MasterBodytext As String
MasterBody=Master.GetRichTextItem(“Body”)
MasterBodytext=MasterBody.GetFormattedText(True,80)
For i=1 To Selected.Count ‘ Scan selected documents (In the order they were added to the database).
Set doc=Selected.getnthdocument(i)
Dim Body As NotesRichTextItem
Dim Bodytext As String
Body=Doc.GetRichTextItem(“Body”)
Bodytext=Body.GetFormattedText(True,80)

. . . INSERT COMPARISON CODE HERE …
Doc.RemoveItem(“Body”)
Set Body = new NotesRichTextItem(Doc,”Body”,TheTextToKeep)
Call Doc.Save(True,false,false)
Next ‘ i

End Sub

Discuss This Question:  

 
There was an error processing your information. Please try again later.
Thanks. We'll let you know when a new response is added.
Send me notifications when members answer or reply to this question.

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

Forgot Password

No problem! Submit your e-mail address below. We'll send you an e-mail containing your password.

Your password has been sent to:

To follow this tag...

There was an error processing your information. Please try again later.

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

Thanks! We'll email you when relevant content is added and updated.

Following