Page 1 sur 1

Déchiffrer automatiquement tous les mails d'une base

MessagePublié: 15 Mars 2010 à 14:45
par mike76
Code : Tout sélectionner
Sub Initialize()
   Dim s As New NotesSession
   Dim db As NotesDatabase
   Dim collection As NotesDocumentCollection
   Dim doc As NotesDocument
   Dim nextdoc As NotesDocument
   
   
   Set db=s.CurrentDatabase
   Set collection=db.Search({Encrypt="1"},Nothing,0)
   If collection.Count>0 Then
      Set doc=collection.Getfirstdocument()
      While Not (doc Is Nothing)
         Set nextdoc=collection.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 encrpying the single token encrypted field
         Call doc.Removeitem("$Seal")
         Call doc.Removeitem("$SealData")
         Call doc.Removeitem("SecretEncryptionKeys")
         Call doc.Removeitem("Encrypt")
         Call doc.Save(True,False)
         Set doc=nextdoc
      Wend
   End If

End Sub