Autor Thema: [Tipp] Mails inkl. Anhänge entschlüsseln  (Gelesen 5453 mal)

Offline TMC

  • Freund des Hauses!
  • Gold Platin u.s.w. member:)
  • *****
  • Beiträge: 3.660
  • Geschlecht: Männlich
  • meden agan
[Tipp] Mails inkl. Anhänge entschlüsseln
« am: 28.04.04 - 20:33:34 »
Hi,

hier habe ich bereits ein Script erstellt, um Mails zu entschlüsseln, allerdings klappte das nicht bei Anhängen.

Bei meinen Web-Recherchen fand ich nur den Tipp, die Anhänge auf der Festplatte zu speichern und erneut zu attachen.

Nach gründlicher Überlegung und einigen Tests habe ich aber nun doch eine Möglichkeit gefunden, die auch für Anhänge klappt  :)

Hierbei setze ich erstmal alle Items auf IsEncrypted = False. Dann erzeuge ich ein Dummy-Item, welche ich verschlüssele. Dann ein Call doc.Encrypt. Zum Schluss nehme ich das Dummy-Item wieder raus.

Klappt bei mir 1A unter R6, sollte unter R5 genau so gehen (hab ich aber noch nicht getestet).

Code
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
   '###################################################################################
   
   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

Matthias

A good programmer is someone who looks both ways before crossing a one-way street.


 

Impressum Atnotes.de  -  Powered by Syslords Solutions  -  Datenschutz