Examples: Encrypt method

  1. This script encrypts the Body item in a document. Other items may also be encrypted if their IsEncrypted property is True. If encryption keys have already been specified for the document, they are used to encrypt the item; otherwise, the current user's public key is used.
    Dim doc As NotesDocument
    Dim item As NotesItem
    '...set value of doc...
    Set item = doc.GetFirstItem( "Body" )
    item.IsEncrypted = True
    Call doc.Encrypt
    Call doc.Save( True, True )
  2. This script encrypts every item in a document. If encryption keys have already been specified for the document, they are used to encrypt the item; otherwise, the current user's public key is used.
    Dim doc As NotesDocument
    '...set value of doc...
    Forall i In doc.Items
      i.IsEncrypted = True
    End Forall
    Call doc.Encrypt
    Call doc.Save( True, True )
  3. This script encrypts the Subject and Body items in a document using the Top Secret encryption key.
    Dim doc As NotesDocument
    Dim itemA As NotesItem
    Dim itemB As NotesItem
    '...set value of doc...
    Set itemA = doc.GetFirstItem( "Subject" )
    Set itemB = doc.GetFirstItem( "Body" )
    itemA.IsEncrypted = True
    itemB.IsEncrypted = True
    doc.EncryptionKeys = "Top Secret"
    Call doc.Encrypt
    Call doc.Save( True, True )