Deleting 'Sent' items NOT in other folders

Is there an elegant way to identify items in the sent mail that are not in other folders?   If an item is put into another folder from the 'Sent' folder, and the item is deleted from the sent folder, the 'copy' in the other folder also disappears.   I assume that that is because only a link is set up between the base item and the folder.

Would like to reduce the size of the 'Sent' folder to be only items that are 'stored' in other folders, or, alternatively, find a way to put an actual copy of the document into the folder, instead of a link, then we can delete all the items in the sent folder completely, until the next run of the cleanup.
Who is Participating?

Improve company productivity with a Business Account.Sign Up

ArunkumarConnect With a Mentor Commented:
Hi mwking !!!

Here is a simple code to acheive your request.

1. Create a Shared Folder Named "Unique Folder" in your mail db.
2. Create an Agent that runs manually from actions menu and runs on selected documents.
3. Paste the following code in your Agent and save it.
4. Go to the sent Folder and select all documents (Ctrl+A).
5. Use Actions menu and Run the agent that you have created on the selected documents.
6. Watch for the status bar for the script completion.
7. Open the "Unique Folder" to find the documents that are found only in your sent box and not in any other Folders !!!!

Here is the Code for the Agent.....

     Dim ss As New notessession
     Dim ws As New notesuiworkspace    
     Dim db As notesdatabase
     Dim view As NotesView    
     Dim doc As notesdocument    
     Dim tempdoc As notesdocument    
     Dim swapdoc As notesdocument
     Dim dc As NotesDocumentCollection
     Dim Ctr As Double
     Set db = ss.CurrentDatabase
     Set view = db.GetView("($Sent)")
     Set dc = db.UnprocessedDocuments
     Set doc = dc.GetFirstDocument
     Ctr = 1
     Do While Not doc Is Nothing
          unid = doc.UniversalID    
          Flag = "NotFound"
          Forall fols In db.Views                                            
               If Not fols.Name = "($Sent)" Then                    
                    If fols.IsFolder Then                        
                         Set tempdoc = fols.GetFirstDocument        
                         If Not tempdoc Is Nothing Then
                              Do While Not tempdoc Is Nothing                              
                                   unid2 = tempdoc.UniversalID                              
                                   If unid = unid2 Then
                                        Flag = "Found"
                                        Exit Do                                                        
                                   End If                                                                                                                      
                                   Set tempdoc = fols.GetNextDocument(tempdoc)
                         End If                        
                    End If                    
               End If                        
               If Flag = "Found" Then
                    Exit Forall
               End If
          End Forall                    
          If Flag = "NotFound" Then
               Call doc.PutInFolder("Unique Folder")              
               Print Ctr & ". document(s) Put in Unique Folder"
               Ctr = Ctr + 1
          End If
          Set doc = dc.GetNextDocument(doc)
     If Ctr = 1 Then
          Print "All the selected documents are found to be in one more folder(s)"
          Print "Successfully transferred " & Ctr - 1 & " documents to Unique Folder"
     End If

Cool Ain't ???

Good Luck !!!


Lotus notes is a Database. Folders are the result of particular query ...It's a view ... When you delete a message , you delete data ...

sent = all data sended
received = all data receive
forum = all messages with response(s)
-> don't touch ...

You can transfer data in another database but I think is a bad way.
Hi Frache !!!

I'm sorry. I did not get you at all.
Could you be more specific and elaborate on your comment ???


Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.


Lotus Notes is a database "like" Access  ,SQL server, or Oracle.
Each user have a little database who contain all messages.
With a database when you want obtain (extract) data, you make a query.
When you click on sent folder, you execute a query.
When you click on received folder, you execute another query.
A "view" is a particular query.
"sent" folder is a view.
"received" folder is a view.
"all messages" is a view
etc ...
With a view you see a part of your database.
When you create a new folder you create a new query = a new view. Not a "real" folder.

When you delete a message in a view you delete data in your database.

If you want duplicate data you must create a new database, and delete data after.
To create new database you can use replication process.
mwkingAuthor Commented:
Regarding the comment from 'frache':  Am aware that Lotus Notes/Domino is a DB.   The real issue is how to identify those items that are listed in the sent folder as being tagged into other folders/views, and to avoid deleting those that are tagged into other folders/views, thereby keeping those items that are, in the users eyes, worthy of keeping.
mwkingAuthor Commented:
On pasting the code into the agent, I get an error message regarding a formula error:
'An operator or semicolon was expected but none was encountered: ss'
referencing the first line of the code.

Did you test this yet??


Make sure that you paste the code in the script options initialise event.

I guess you are trying to paste
it in the formula event.

Good Luck !


mwkingAuthor Commented:

We are getting errors in the Script Initialise event.   Please review the code and let us know.   The strange stan-alone 'If' is flagged and the error posted is :
"Agentname: Initialize: 34: Unexpected En-of-Line; Expected : Expression"

If we remove the "If", we get a pile of mis-matched "End" statements.

I suspect that there is a condition missing in the version of the code posted above>


Hi Mic,

I have just checked the script that i have posted.

Check - manually from actions menu.
Run on - Selected documents
Copy the code to clipboard

paste it between the sub & End sub of the initialize event.

I did not get any errors and the code is perfectly workin.

All the loops and conditions are complete.  

Good Luck !


Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.