Subject: Accessing all dbs in given folder on server
You have 2 options:
Easiest option, set up a multiple database full text index and search using the global search functionality (see the Administrators Help for information on this).
Do some code. Below is a squirrely way of doing it, but you get the idea…
Sub Initialize
On Error Goto oops ' this will just skip a db (in case there is a problem searching it)
Dim sess As New NotesSession
Dim loopdb As NotesDatabase
Set loopdb = sess.CurrentDatabase ' getting the current database so we know what server we're running on
Dim dbdir As New NotesDbDirectory (loopdb.Server) ' get all databases for the current server
Dim coll As NotesDocumentCollection
Dim tempdoc As NotesDocument
Dim newsletter As NotesNewsletter
' get the search term
Dim srchTerm As String
srchTerm = Inputbox("What", "What are you searching for?")
' create an email to hold the results
Dim maildoc As New NotesDocument(loopdb)
maildoc.Form = "Memo"
maildoc.SendTo = sess.CommonUserName
maildoc.Subject = "Search of " & loopdb.Server & " mail databases for " & srchTerm
Dim rtitem As New NotesRichTextItem (maildoc, "Body")
' loop through the databases on the server
Set loopdb = dbdir.GetFirstDatabase(1247) ' getting databases only (not templates)
Do Until loopdb Is Nothing
' check and see if the database we're on is in the mail directory
If Instr(loopdb.FilePath, "mail\") > 0 Then
Print "on " & loopdb.Title
' have to open it to search (dbdir methods don't open the database when they get it)
loopdb.Open "",""
' do a search of the database (assuming the dbs have a ft index and you have access to the database)
Set coll = loopdb.FTSearch(srchTerm, 0)
' if there is a collection, grab its results
If coll.Count > 0 Then
' turn the collection into a newsletter document
Set newsletter = New NotesNewsletter(coll)
Set tempdoc = newsletter.FormatMsgWithDoclinks(loopdb)
' pop this newsletter document into our email
tempdoc.RenderToRTItem rtitem
rtitem.AddNewLine 2
End If 'end checking to see if we have results
End If
resumehere:
' keep looping through databases
Set loopdb = dbdir.GetNextDatabase
Loop
' go ahead and send the email
maildoc.Send False
Exit Sub
Subject: RE: Accessing all dbs in given folder on server
Try it out, the agent code I gave you functions as coded if you put it in a database on the server you are searching (I made a minor tweak, so if you copied it already copy it again).
Then, start mucking around. For the FTSearch, it will do a search same as whatever you would type in the search bar in a notes client. So, you could put in “apples, oranges” in the input box and it would function same as if you did it through the client full text search. You can get as complicated as you need to same as in client, i.e. “(apples AND oranges) NOT bananas”, or “fruit, a*”. Just play around with typing different stuff in the input box.
Lastly, I used a newsletter simply because it handily provides links to the documents. You can certainly use some other method, I’ve also done it by looping through the collection and writing info about the document on each line. Whatever suits you.