I’ve had a few cases recently where some users ended up with multiple archives because they moved from having a local archive to a server based archive for their email. When this happens the user eventually asks if there is any way to merge the two archives so that just have a single place to look for their archived email.
The BOFH Admins will gladly help the user out by telling them that they can copy/paste the emails from one archive to the other. This takes forever and the user normally gives up or ends up with duplicate emails. Sometimes it’s fun being a BOFH Admin Laughing
But there is a way to easily merge two archives ( or any two Lotus Domino databases for that fact ) using LotusScript. You can even take into account all the folders in both databases and copy over the folders ( including their design ) for folders in the source database that don’t already exist in the destination database. All you need is the following agent. It’s not 100% perfect, it relies on the fact that every document is in a folder so it won;t work for databases that use 100% views but it could easily be modified for that if you need it.
I hope it helps somebody out there. It just saved me a load of time…
%REM Agent Merge Archives Created Dec 14, 2010 by Declan Lynch/CZARNOWSKI Description: Copies all documents from a source database to a destination database including folders and folder designs %END REM Option Public Option Declare Sub Initialize Dim s As New NotesSession Dim w As New NotesUIWorkspace Dim sourceDB As NotesDatabase Dim sourceView As NotesView Dim sourceViewColl As NotesViewEntryCollection Dim sourceViewEntry As NotesViewEntry Dim sourceFolders() As String Dim destDB As NotesDatabase Dim destView As NotesView Dim destViewColumn As NotesViewColumn Dim destDoc As NotesDocument Dim colCount As Integer ' Ask for the Source DB and See If It Exists Dim selectedSourceDB MessageBox "Please Select the Source Database",64,"Lotus Notes Database Merger" selectedSourceDB = w.Prompt( 13, "Choose the source database to copy the folders from","Lotus Notes Database Merger" ) If IsEmpty( selectedSourceDB ) Then MessageBox "Source database not selected", , "Lotus Notes Database Merger" Exit Sub End If Set sourceDB = s.GetDatabase( selectedSourceDB(0), selectedSourceDB(1), False ) If sourceDB is Nothing Then MessageBox "Error Opening The Source Database", , "Lotus Notes Database Merger" Exit Sub End If ' Ask for the Destination DB and See If It Exists MessageBox "Please Select the Destination Database",64,"Lotus Notes Database Merger" Dim selectedDestDB selectedDestDB = w.Prompt( 13, "Choose the destination database to copy the folder to","Lotus Notes Database Merger" ) If IsEmpty( selectedDestDB ) Then MessageBox "Destination database selected.", , "Lotus Notes Database Merger" Exit Sub End If Set destDB = s.GetDatabase( selectedDestDB(0), selectedDestDB(1), False ) If destDB is Nothing Then MessageBox "Error Opening The Destination Database", , "Lotus Notes Database Merger" Exit Sub End If ' Get All The Folders In The Source DB ForAll v In sourceDB.Views If v.IsFolder Then Print "Processing Folder : " + v.Name Set sourceView = sourceDB.getView(v.Name) Set sourceViewColl = sourceView.Allentries Set destView = destDB.getView(v.Name) If destView is Nothing Then ' No existing Destination folder. Create A New Folder Call destDB.EnableFolder(v.Name) Set destView = destDB.getView(v.Name) ' Copy the Source Folder Design ' Remove all The view columns From the folder While destView.ColumnCount > 0 Call destView.RemoveColumn(destView.ColumnCount) Wend ' Copy All the ViewColumns from the source Folder For colCount = 0 To sourceView.ColumnCount-1 Set destViewColumn = destView.CopyColumn(sourceView.Columns(colCount), colCount+1) Next End If ' Copy All The Documents In The Folder To The Destination Database Set sourceViewEntry = sourceViewColl.GetFirstEntry Do Until sourceViewEntry Is Nothing Set destDoc = sourceViewEntry.Document.CopyToDatabase(destDB) Call destDoc.PutInFolder(v.Name) Set sourceViewEntry = sourceViewColl.GetNextEntry(sourceViewEntry) Loop End If End ForAll MessageBox "Processing Complete",64,"Lotus Notes Database Merger" End Sub