notesDocument .Encrypt(NotesUserID) not working like I hoped

I can't get the method notesDocument.Encrypt working using a userid or idfile. Tried v9 and v10.
The method using the NotesUserID as a parameter is accepted, but keeps telling me 'You cannot access portions of this document because it is encrypted and was not intended for you, or you do not have the decryption key', the second method using idfile and password didn't work.
Call notesDocument .Encrypt(userid)

Call notesDocument .Encrypt(idfile, password)

https://help.hcltechsw.com/dom_designer/10.0.1/basic/H_ENCRYPT_METHOD.html

What I try to do is decrypting documents in hundreds of mail databases, using a modified script found in the IBM site.
nID is the notesUserID of the mailfile owner and can read the encrypted message, Doc is the encrypted mail.

Function DecryptDocument(Doc As NotesDocument, nID As notesUserID) As Boolean
    On Error Goto ErrorHandler
    Dim bIsencrypted As Boolean
    'The below loop is mandatory to ensure that all $FIle entries are unecrypted
    Forall i In doc.items
        If (i.isencrypted) Then
            bIsencrypted = True
            i.isencrypted = False
        End If
    End Forall
If (Not bisencrypted) Then
    DecryptDocument = True
    Exit Function
End If
'Must have at least 1 field encrypted in order to call Encrypt method
doc.Replaceitemvalue("tmpEncrypt","EncryptMe").IsEncrypted = True
Call doc.Encrypt(nID) 'Error: You cannot access portions of this document because it is encrypted and was not intended for you, or you do not have the decryption key
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("tmpEncrypt")
Call doc.removeItem("encryptionKeys")
Call doc.save(True, False)

DecryptDocument = True    
Exit Function    

ErrorHandler:
Msgbox “DecryptDocument: " & Error & " (” & Err & ") on line " & Erl
DecryptDocument = False
Exit Function
Resume Next

End Function

Any suggestions?