Agent that will find databases that have more than one $Inbox

After we upgraded our mail template using the load convert command recently, we found that a few very out of the ordinary problems popped up.

For some of these cases, we found that there were two ($Inbox) folders in the mail file when looking through designer.

Many of the cases, the original ($Inbox) was listed first, so Outlook connector, Webmail, and BlackBerry Enterprise Server was seeing that old Inbox, but Lotus Notes client sees the new ($Inbox) where new mail is being delivered.

Has anyone got an idea on how to find all the mail files on a server that have two ($Inbox) folders?

Any help or agent code would be gladly appreciated.

Subject: Agent that will find databases that have more than one $Inbox

Here is some code, you need to add a loop round the return nid’s, but the basic idea is here.

Sub Initialize

Dim targetdb As New NotesDatabase(“”, “”)

Dim tserver As String

Dim formname As String

Dim collection As NotesDocumentCollection

Dim dbDir As NotesDbDirectory

Dim dbFilePath As String

Dim dbFolder As String

Dim msg As String

Dim fn As Integer

Dim memo As NotesDocument

Dim search As String

Dim language As String

Dim nc As NotesNoteCollection

On Error Resume Next

fn = Freefile()

Open “logfile” For Output As fn

tserver = “your server”

Set dbDir = New NotesDbDirectory(tserver)

Set targetdb = dbDir.GetFirstDatabase(TEMPLATE_CANDIDATE)

Do While Not(targetdb Is Nothing)

If targetdb.Title <> “Database Stub” Then

dbFilePath = targetdb.FilePath

dbFolder = Ucase(Strleftback(dbFilePath, ""))

If Lcase(Left$(dbFolder, 4)) = “mail” Then

formname = getDefaultFormName(tserver, dbFilePath) Call targetdb.Open(tserver, dbFilePath)

Set nc = targetdb.CreateNoteCollection(False)

nc.SelectFolders = True

Call nc.BuildCollection

Set memo = targetdb.GetDocumentByID(nc.GetFirstNoteId)

If Not memo Is Nothing Then

If memo.Title = “($Inbox)” Then

count = count + 1

End If

Print #fn, targetdb.Title

End If

End If

Set targetdb = dbDir.GetNextDatabase

Loop

Close fn

End Sub

Subject: RE: Agent that will find databases that have more than one $Inbox

Something more like this, I think:

Do While Not(targetdb Is Nothing)

If Lcase(Left$(targetdb.FilePath, 4)) = “mail” Then

Call targetdb.Open(“”, “”)

Set nc = targetdb.CreateNoteCollection(False)

nc.SelectFolders = True

nc.SelectionFormula = {$TITLE = “($Inbox)”}

Call nc.BuildCollection

if nc.Count > 1 then

Print #fn, targetdb.filepath

End If

End If

Set targetdb = dbDir.GetNextDatabase

Loop

There are better ways to display a report, of course, that let you include doclinks to the databases and so on, but this will get you the information you need.

If you have an ID with sufficient authority, of course, you can also iterate thru the note collection and delete the extra inbox, based on the date.

One other thing to note: if user mail files have multiple inboxes, there’s a good chance they’re inheriting them from the template on their server, so you may want to scan and fix the templates on all servers rather than the mail files.

  • Andre Guirard, IBM/Lotus Development

Useful blog: Best Practice Makes Perfect

For faster answers, be C R I S P Y

Subject: RE: Agent that will find databases that have more than one $Inbox

Nice improvement (I wasn’t aware of the nc.SelectionFormula option).

Something to keep in mind: in a multilingual mail-file you will have more than one $Inbox. So you could add a test to see if all the $Language-fields are different in a single mail-file.

Subject: RE: Agent that will find databases that have more than one $Inbox

Thanks Andre and Rob,

I hate to be a freeloader, but I’m not a Lotuscript person.

How would I be able to add both of your bits of code together to form a working Lotusscript agent?

Additionally, would I put this into a sample database (say locally) and run the code from an action agent which would produce results in a view?

I think this would be useful to those who have ever done a mass mail template upgrade with load convert.

Unfortunately, the problem we have is that there is alot of legacy garbage around in our environment and there were multiple iterations of customized mail templates and the reason I need to run something like this is that some of the $Inbox views are specifically set to inherit their design changes in the design element properties from an older mail template.

So when load convert runs, it doesn’t update the existing $Inbox, but adds a second one.

We get some very strange behavior after the upgrade…and to make matters worse, we have several Outlook Connector users, so the problem is not necessarily apparent. It seems that webmail/DWA/Outlook connector look at one $Inbox while the Lotus Notes client looks at the second (proper) one in the list.

Thanks anyways!