This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal


Mar 12, 2016, 4:32 PM
4 Posts

Programmatically Opening and Reading a NotesDocument using C#

  • Category: Other
  • Platform: Windows
  • Release: 9.0.1
  • Role: Developer
  • Tags:
  • Replies: 1

I am trying to open and read a Notes document using the Domino API in C#. I am following the example described here. Here is my code:

      HANDLE hCC = NULLL;

      STATUS stat = 0; // 16-bit unsigned integer

      HANDLE hID = NULL;

 

 

      uint nid = 0;

     

      // get the new document's noteid 

      nid = Convert.ToUInt32(noteid, 16);

     

      // returns 690. What does that mean??

      stat = NotesEntries.NSFNoteOpenExt(this.m_hDb, 

                                         nid,

                                         NotesEntries.OPEN_RAW_MIME, 

                                         ref hNote);

 

      

 

I can retrieve a message's noteid string, and I use that to call NotesEntries.NSFNoteOpenExt(), but it is returning an integer code stat variable and I don't know what to do with that. According to this site, the function returns a "status from this call -- indicates either success or what the error is. The return codes include: NOERROR, ERR_DIRECTORY, ERR_NOACCESS, ERR_INVALID_ITEMUNK." However I am only getting an integer value of 690. What does that mean? Where are these statuses defined?

Mar 14, 2016, 8:48 AM
103 Posts
A bit more complex..

I've not played with C# so this may need a bit of interpretation on your part.

The return value from the API call is an error code (0 for no error).  Error codes are bits so are pretty much unreadable  To get the error in a readable format you will need to do a bit more work.  The following is using C e.g:

STATUS        string_id = ERR(_error);  // this removes mask bits from the returned error that can cause the next call to return duff info. ERR() is a macro to do the work for you.

WORD        text_len;
 char            error_text[MAXSPRINTF];

text_len = OSLoadString(NULLHANDLE,
                            string_id,
                            error_text,
                            sizeof(error_text)); // this will get the string related to the error code.

 

If however you want to use the error codes directly these are mostly defined in the xxxerr.h of the type you are using (in your case nsferr.h), here's a bit of it...

#define    ERR_DIRECTORY        PKG_NSF+28
    errortext(ERR_DIRECTORY,    "This function is inappropriate for file system directories.")
#define    ERR_NOT_DIRECTORY    PKG_NSF+29
    errortext(ERR_NOT_DIRECTORY, "This function is only appropriate for directories.")
#define    ERR_ITEM_DEF_TYPE    PKG_NSF+30
    internaltext(ERR_ITEM_DEF_TYPE, "Cannot add item def - type unknown")
#define    ERR_BUCKET_STRUCT        PKG_NSF+31
    internaltext(ERR_BUCKET_STRUCT,    "Invalid structure in bucket")

 

As it's C what you get back from the call NSFNoteOpenExt is an error code and a handle to the note you are after (in your case the handle is hNote).  The note handle is then used in other calls to get at fields within the note.

Looking at the example BlogMIME.cs as soon as there is an error it exits without identifying the error:

if (stat >0)

    goto XEnd;

 

You may want to manually check that the noteID that you are using is in the database first.  This can be done with the admin client, or if you have a test database with one document in it you can check the properties of the document.

 

In the above the noteID is B496. If however the noteID that you have is more like 80000000 then that is not actually a note, that's a category (a sudo noteID used in views).


This forum is closed to new posts and responses. Individual names altered for privacy purposes. The information contained in this website is provided for informational purposes only and should not be construed as a forum for customer support requests. Any customer support requests should be directed to the official HCL customer support channels below:

HCL Software Customer Support Portal for U.S. Federal Government clients
HCL Software Customer Support Portal