Manage Learn to apply best practices and optimize your operations.

Recover lost folders

This tip shows you how to recover lost files using a LotusScript agent.

You know the situation. CONVERT task has deleted some of private folders in the mail database because of a missing flag, "Prohibit design refresh." How do you recover them easily? It simple, the provided LotusScript coded agent will restore them, comparing the list of private folders in the stricken server (current) database and its local replica -- backup of the database.

  Code: Sub Initialize
 Dim ss As New NotesSession
 Dim uiw As New NotesUIWorkspace
 Dim cdb As NotesDatabase
 Dim replika As New NotesDatabase("", "")
 Dim doc As NotesDocument
 Dim coll As NotesViewEntryCollection
 Dim ventry As NotesViewEntry
 Dim cfolder As String
 Dim cview As NotesView
 Dim slozka List As Integer
 Dim n As Integer
 Set cdb = ss.CurrentDatabase
 If Not replika.OpenByReplicaID( "", cdb.ReplicaID) Then
  Messagebox "Local replica was not found!"
  Exit Sub
 End If
 n = 1
 ' List of existing folders
 Forall s In cdb.Views
  If s.isfolder Then
   If Left$(, 1) <> "(" Then
    n = n + 1
   End If
  End If
 End Forall
 ' List of folders in local replica
 Forall s In replika.Views
  If s.isfolder Then
   If Left$(, 1) <> "(" Then
    If Iselement(slozka( Then
    Else ' lost folder
     Set coll = s.AllEntries
     Print "Restore: " &, Cstr
(coll.Count) & " documents."
     If coll.Count > 0 Then
      Call cdb.EnableFolder(
      Set ventry = coll.getFirstEntry
      While Not ventry Is Nothing
       If ventry.IsDocument 
        Set doc = 
cdb.getdocumentbyunid( ventry.UniversalID)
        If Not doc Is 
Nothing Then
        End If
       End If
       Set ventry = 
coll.GetNextEntry( ventry)
     End If
    End If
   End If
  End If
 End Forall
End Sub

Do you have comments on this tip? Let us know.

This tip was submitted to the tip exchange by member Milos Safarik. Please let others know how useful it is via the rating scale below. Do you have a useful Notes/Domino tip or code to share? Submit it to our monthly tip contest and you could win a prize and a spot in our Hall of Fame.

Dig Deeper on LotusScript

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.




  • iSeries tutorials's tutorials provide in-depth information on the iSeries. Our iSeries tutorials address areas you need to know about...

  • V6R1 upgrade planning checklist

    When upgrading to V6R1, make sure your software will be supported, your programs will function and the correct PTFs have been ...

  • Connecting multiple iSeries systems through DDM

    Working with databases over multiple iSeries systems can be simple when remotely connecting logical partitions with distributed ...