Sub Initialize '################################################################################### 'Purpose: 'Decrypt emails '--------------------------------------------------------------------------------------------------------- 'Usage: 'Create a Lotus Script agent - "All documents in database" and copy this code to "Initialize". '*IMPORTANT*: Run this agent with the same public key (ID-file) that was used to encrypt the documents. 'Otherwise this will not work! '--------------------------------------------------------------------------------------------------------- 'Version Date Programmer '1.10 04/28/2004 Matthias TMC '################################################################################### ' Quelle_ https://atnotes.de/index.php?board=5;action=display;threadid=15495 On Error Goto ErrorHandler Dim session As New Notessession Dim db As Notesdatabase Dim dc As Notesdocumentcollection Dim dcEncrypted As Notesdocumentcollection Dim item As NotesItem Dim doc As notesdocument Dim iCounter As Integer Dim iAllCount As Integer Set db = session.Currentdatabase Set dc = db.allDocuments '----> We need an empty doccollection Set dcEncrypted= db.GetDocumentByUnid(db.Views(0).UniversalID).Responses '<---- '------> Search for encrypted docs and put them in the 2nd doc collection iCounter = 0 iAllCount = dc.Count Set doc = dc.Getfirstdocument While Not doc Is Nothing '---> See progress iCounter = iCounter +1 Print iCounter & "of " iAllCount "docs processed." '<--- If doc.IsEncrypted And (doc.IsDeleted = False) Then Call dcEncrypted.AddDocument(doc) End If Set doc = dc.Getnextdocument(doc) Wend '<------- '-----> Message.... If dcEncrypted.Count = 0 Then Msgbox "No documents in this database are encrypted.", 64, db.Title Exit Sub Else If Not Messagebox (dcEncrypted.Count & " documents in this database are encrypted." &Chr(10) &Chr(10)_ & "Do you really want to decrypt these documents? ",1 + 32,db.Title) = 1 Then Exit Sub End If '<------- '--------> Now we remove the encryption stuff iCounter = 0 iAllCount = dcEncrypted.Count Set doc = dcEncrypted.GetFirstDocument While Not doc Is Nothing 'See progress iCounter = iCounter +1 Print iCounter & "of " iAllCount "docs processed." 'Decrypt..... Forall i In doc.Items If i.IsEncrypted Then i.IsEncrypted = False End If End Forall 'Create a dummy-item for encryption only (so that 'Call doc.Encrypt' does work) Dim dummyitem As NotesItem Set dummyitem = New NotesItem ( doc, "DummyItem", "" ) dummyitem.IsEncrypted = True 'Let's encrypt the document and save it. But only our dummy-icon wil be encrypted. Call doc.Encrypt Call doc.Save(False, False) 'Now let's remove the encryption-items and save once more While (doc.HasItem("Encrypt")) Set item = doc.GetFirstItem("Encrypt") Call item.Remove Wend While (doc.HasItem("$Seal")) Set item = doc.GetFirstItem("$Seal") Call item.Remove Wend Call doc.Save(False, False) 'Now we clean up and remove the dummy item While (doc.HasItem("dummyitem")) Set item = doc.GetFirstItem("dummyitem") Call item.Remove Wend 'And once more a save..... Call doc.Save(False, False) Set doc = dcEncrypted.GetNextDocument(doc) Wend '<----------- Msgbox "The" & dcEncrypted.Count & " documents are decrypted now!", 64, db.Title ExitScript: Exit Sub ErrorHandler: Msgbox "Error: " & Err & " - " & Error$ & Chr(10) & Chr(10)_ & "Line: " & Erl & Chr(10)_ ,48,"An error occured" Resume ExitScript End Sub