1
votes

On a XPage I'm using the following code to load some text from a document's MIME entity:

var dcl:NotesDocumentCollection=database.getView("myView").getAllDocumentsByKey("key",true);
var doc:NotesDocument=dcl.getFirstDocument();
var entity:NotesMIMEEntity=doc.getMIMEEntity("data");
var text=entity.getContentAsText();

This works without errors. When replacing database with sessionAsSigner.getCurrentDatabase() an error is raised, stating that the MIME entity is null (testing environment = Server: Notes 8.5.3 | Client: Firefox 15). Here is some additional information I got from manually debugging the code:

  • sessionAsSigner is a valid NotesSession object
  • doc is a valid NotesDocument that is readable for me, i.e. using the getItemValue methods works without error
  • doc.hasItem("data") is true, i.e. the MIME entity field exists

However, using doc.getMIMEEntity("data") returns null even though it's not empty. The problem even occurs for documents without authors and readers fields. Why does using sessionAsSigner allow to open the document and get item values, but not allow to read the MIME entity?

1

1 Answers

1
votes

To solve the issue, call

sessionAsSigner.setConvertMime(false);

before using the sessionAsSigner object. This prevents MIME items from being converted to rich text when opening a document. Otherwise NotesDocument.getMIMEEntity returns null.