title: Creating a view and agent in multiple databases
body: <p>The problem I am encountering is that some of the messages are not accessible by the user ID file, I would like to skip these files instead of the agent crashing out. The error message received is as follows:</p>
  
  <p><img src="https://i.stack.imgur.com/ntTaO.jpg" alt="decryptionError"></p>
  
  <p>Using the view approach if this happened I was able to delete the document temporarily and re-run the agent but if there is a way to skip documents it would be a great help. </p>
  
  <p>Thanks for the help guys. </p>
  
  <p>Ok I have amended the code to a point where I am almost comfortable with it.</p>
  
  <p>Sub Initialize</p>
  
  <pre><code>Dim s As New notessession
  Dim db As notesdatabase 
  Dim view As notesview
  Dim doc As notesdocument
  Dim nextdoc As notesdocument
  
  
  Set db = s.currentdatabase
  If view Is Nothing Then
      Set view = db.CreateView("Encrypted",{Encrypt="1"})
  End If  
  Set doc = view.getfirstdocument
  
  On Error Goto ErrorHandler
  
  While Not doc Is Nothing        
  nextDocument:
      Set nextdoc = view.getnextdocument(doc)
              'The below loop is mandatory to ensure that all $File entries are unecrypted
      Forall i In doc.items
          If i.isencrypted Then
              i.isencrypted=False 
          End If 
      End Forall
  
          'Must have at least 1 field encrypted in order to call Encrypt method
      Dim temp As New NotesItem(doc,"tempjunk","temp")
      temp.IsEncrypted=True
      Call doc.encrypt
      Call doc.save(True, False)
          'This portion can now remove the fields relative to encrypting the
          'single token encrypted field.
      Call doc.removeitem("$Seal")
      Call doc.removeitem("$SealData")
      Call doc.removeitem("SecretEncryptionKeys")
      Call doc.removeitem("Encrypt")
      Call doc.removeItem("tempjunk")
      Call doc.save(True, False)
      Set doc = nextdoc 
  Wend
  Exit Sub
  
  ErrorHandler:
  On Error Resume nextDocument
  Exit Sub
  </code></pre>
  
  <p>End Sub</p>
  
  <p>The error handling is not playing nice;</p>
  
  <p><strong>On Error Resume nextDocument</strong> is showing up as an error.
  I have tried suppressing all of the error warnings which seems to attempt to strip the encryption but I think they body of the messages is being destroyed as a result. </p>