In other words, it doesn't want to delete a document in the back end when you obtained the NotesDocument handle from the front end -- a document you have open. Since you say you eliminated all the UI stuff from your code, I assume it's that you're running on a NotesDocument from the UnprocessedDocuments collection, but it's the document you have open. So if you get this error, it would seem that you should trap it and try deleting the document a different way, via NotesUIWorkspace.CurrentDocument.DeleteDocument. Or, if it needs to be a hard delete, respond to the error by closing the document (uidoc.close), and then delete the NotesDocument from memory (Delete statement), re-get the document from the back end using the noteID which you have previously stored, and then delete it.
If I've understood the problem correctly and this approach works for you, please reply, because in that case I'd like to technote it. Thanks.
Trouble with Removeall Method in LS... (Lee A. Whitney 16.Jan.09)
Feedback response number AGUD7NR4Q2 created by Andre Guirard on 01/28/2009
. . The error text is more useful than ... (Andre Guirard 17.Jan.09)
. . . . Agreed... (Lee A. Whitney 17.Jan.09)
. . . . . . "Cannot remove NotesDocument when i... (Andre Guirard 28.Jan.09)
. . . . . . . . Latest... (Lee A. Whitney 1.Feb.09)
. . . . . . . . . . wondering whether it might have som... (Andre Guirard 9.Feb.09)
. . . . . . . . . . . . Preview pane (Lee A. Whitney 14.Feb.09)