How do I delete multiple mail databases?

Hello, what I want to do seems fairly simple. How do I delete a list of mail files? I have a list of mail files of terminated users and want to delete them all at once.

Based on the domino log where there are references to a mail file with no associated person document I generate a list of potential terminated users. Once validated that they are indeed no longer with the company I want to delete them. It takes a long time to manually delete hundreds of mail files via the Admin client.

I am not experienced with Lotus Script but I am willing to try. Does anyone have some ideas on how to script this? Thanks!

First of all you need your list of paths in a variable. You could do that in different ways depending on how the list of paths looks. If e.g your list of databases to delete us a comma separated list like this:

Mail\deleteme1.nsf,Mail\deleteme2.nsf,Mail\deleteme3.nsf

then you can easily build an array from this with one line of code:

Dim filePaths as Variant
filePaths = Split("Mail\deleteme1.nsf,Mail\deleteme2.nsf,Mail\deleteme3.nsf", ",")

If you have the list e.g. in an excel file, then you could use excel formulas to construct something like this:

Dim filePaths(2) As String

filePaths(0) = “Mail\deleteme1.nsf”
filePaths(1) = “Mail\deleteme2.nsf”
filePaths(2) = “Mail\deleteme3.nsf”

In both cases you then run through all values in the array, open the database and remove it:

Dim db as NotesDatabase
Dim i as Integer
For i = 0 to Ubound(filePaths)
  Set db = New NotesDatabase( "YourServerName", filePaths(i))
  If db.IsOpen Then
    Call db.Remove
  End If
Next

Of course this is only the absolute minimum of the needed code, it does not contain any error handling, logging, or any other security measurment. You could replace the line

Call db.Remove

With

Print "Remove", db.Title, "FilePath:",db.FilePath

Then you could see on the console / in log.nsf which databases would be removed before really removing them…

That's very helpful thank you Torsten Link. It amazes me how fast people can be ready with an intelligent and logical suggestion. The path is the same for all mail databases being removed so the one line code looks tantalizing and what I was indeed looking for. This should hopefully give me enough information to try to create something on my own. There is definitely a gap between what I know and what you are suggesting but I think I can bridge the gap with some trial and error.

You'll have to excuse me as I am not a coder so is that LotusScript that you are suggesting? Would I use Designer to validate the code? Thanks for your valuable time!

Hi Dave,

Yes, this is a LotusScript Code.

You can create an agent using Domino Designer.

Please refer to the below URL for more information on how to create an agent.

Creating an agent

Regards,

Amit Sharma

Hello Dave,

There is a tool in the OpenNtf "Orphan Database Detector" which will detect the orphan databases on the Domino server which doesn't have a person record in the Domino directory.

https://www.openntf.org/main.nsf/project.xsp?r=project/Orphan%20Database%20Detector/reviews

Using this template we can generate a report. Now your requirement is to delete the orphan database in bulk.

This tool has been further customised here (ntf attachment) to have an action button to select the documents from report and delete multiple orphan databases on the server at once.

===LS CODE===

Sub Click(Source As Button)
If (Messagebox ("Do you want to delete selected databases permanently from the server ?", 4, "Are you sure?") = 6) Then
Print "Starting to delete"
Dim s As New NotesSession
Dim db As NotesDatabase
Dim dc As NotesDocumentCollection
Dim doc As NotesDocument
Set db = s.CurrentDatabase
Set dc = db.UnprocessedDocuments
Set doc = dc.GetFirstDocument
While Not doc Is Nothing
Dim mdb As NotesDatabase

'Change the server name to yours example here given as DomSrv/NDTech"

Set mdb = s.GetDatabase("DomSrv/NDTech", doc.Orphandbpath(0))
Print " About to delete " & doc.Orphandbpath(0)
Call mdb.Remove
Print "Deleted " & doc.Orphandbpath(0)
Set doc = dc.GetNextDocument(doc)
Wend
Else
Print "User cancelled Delete db operation."
End If
End Sub

===LS CODE===

Tool screen shot.

When you choose "Yes" it deletes the selected database on the server as shown below.

It is always recommended test the tool test environment first before you perform on the production. To configure the tool refer the openntf zip file which has a word document how to configure it. You might also need full access administration rights on the Domino server to delete the database on the server.

Disclaimer: HCL Support has coded a "tool" to assist you in getting over a specific requirement, as asked in this forum thread. However, HCL couldn't test the codes thoroughly for all possible conditions and as such the tool should be treated as an untested and unsupported tool with no implicit/explicit warranties from HCL. Neither can this tool be customized further.

Use the tool at your own risk. HCL does not provide you with rights to distribute or share the tool internally or on public domain. HCL can't be held responsible for any problems or issues that may arise due to the usage of this tool in any environment.

HCL Support recommends that you move the affected databases to a controlled environment, run the tool over them and verify the results. Once you're satisfied with the results. Carry the test over to the production system for usage. Once you've completed with the task, please be sure to delete the tool from the environment.

Thank you

Regards

Shrikant J

Hi Shrikant, thank you for that detailed information. That looks like a great tool for what I am trying to accomplish. The two hyperlinks you provided I am having problems with. "This shared file or folder link has been removed or is unavailable to you." for the ntf file and open ntf URL simply says "No reviews available".

Thanks for any follow up you can provide.

Hi Dave,
The template link is accessible. Plz check.
Thank you.
Regards
Shrikant J

Hello Shrikant,

I think you should add this tool to the Domino server by default: it should not be a great effort... ;-)

I regret to say that I haven't been able to get this working. The "Orphan Database Detector" does not identify the proper databases nor does "deleteDB" functionality work for me. Not being a programmer I have not been able to successfully modify any of Torsten's proposed code to work in my environment either, even as a test with dbs on my local machine.

It is entirely possible that the failure is on my end in using Shrikant's ntf and a lack of knowledge of LotusScript that prevents me from success in this case.

I understand that this is a very basic question and that I am not here to be taught LotusScript but I feel this is very close to being able to work but I get a "variable not declared" for "i" in this test script taken from @Torsten Link above.

I still wish to thank those who provided information and I was looking forward to "Mark as Correct Answer". I continue to try to get this working because we very much need this functionality.

Hi Dave,

You should declare the variable "i" that you are using in your code. That's why the error appears.

Place one more line of code like -->

Dim db as NotesDatabase

Dim i as Integer

After this declaration, you can give a reference of "i" anywhere in the subsequent code.

Please refer to the below URL for more explanation of the error.

Variable not declared: <name>

There is one more way to skip the above error.

You can still avoid to declare "i" in your code and instead remove/comment line "Option Declare" as shown below:

Similar information is mentioned in the URL provided above.

However, I would recommend not to go by this approach. Declare all the variables that you are using in your code.

Regards,

Amit

Amit is absolutely right: Dim i as Integer is missing. I modified my answer to contain that line, so that it is "complete" for somebody stumbling about this later.