DotNetToDomino – A .NET Wrapper for HCL Notes/Domino

Integrating modern .NET applications with HCL Notes/Domino has traditionally involved Java libraries, or c/c++ code. DotNetToDomino takes a different approach: it provides a .NET object model on top of the HCL Notes/Domino C API.

The goal is to work with familiar Notes objects from C# while communicating directly with the installed Notes/Domino runtime.

Installation

Install the library from NuGet:

dotnet add package DotNetToDomino --prerelease

DotNetToDomino requires:

  • .NET 10
  • An installed HCL Notes/Domino runtime 64-bit
  • A valid Notes ID for authenticated operations
  • Access to notes.ini

The HCL native DLLs are not included in the NuGet package.

Creating a Notes session

using DotNetToDomino;

using var session = new NotesSession(
    @"C:\Program Files\HCL\Notes",
    @"C:\Program Files\HCL\Notes\notes.ini",
    Environment.GetEnvironmentVariable("NOTES_TEST_ID_PASSWORD"));

Console.WriteLine($"User: {session.UserName}");
Console.WriteLine($"Platform: {session.Platform}");
Console.WriteLine($"Notes version: {session.NotesVersion}");

The password should be provided through an environment variable or a secure secrets solution rather than being hard-coded.
For Notes client windows platform new NotesSession() can also be used if the Registry values are correct and the client can be found that way.

Opening a database

A local database can be opened with an empty server name or by using local.

using var database = session.GetDatabase(
    server: "",
    filePath: "example.nsf",
    createOnFail: false);

if (database is null)
{
    Console.WriteLine("The database could not be found.");
    return;
}

Console.WriteLine($"Title: {database.Title}");
Console.WriteLine($"File path: {database.FilePath}");
Console.WriteLine($"Replica ID: {database.ReplicaID}");

A remote Domino database can be opened by specifying the server:

using var database = session.GetDatabase(
    "ACME01",
    "apps/example.nsf",
    createOnFail: false);

Creating a database

using var database = session.GetDatabase("",
"new-example.nsf",createOnFail: true);

if (!database.IsOpen)
{
    database.Create();
}

database.Title = "My new database";
database.Categories = "Integration, .NET";

Database metadata such as the title and categories is written directly.
Document changes must be persisted with document.Save().

Creating and saving a document

using var document = database.CreateDocument();

document.ReplaceItemValue("Form", "Main").recycle()
document.ReplaceItemValue("Subject", "Created from .NET").recycle()
document.ReplaceItemValue("Status", "New").recycle()

document.Save();

ReplaceItemValue returns a Notes item that can be recycled immediately after use.

Reading documents from a view

using var view = database.GetView("All Documents")
    ?? throw new InvalidOperationException("The view does not exist.");

using var document = view.GetFirstDocument();

if (document is not null)
{
    Console.WriteLine(document.GetString("Subject"));
}

Objects implementing IDisposable should be used with using or using var. This ensures that native handles are closed and the corresponding Notes objects are recycled.

DotNetToDomino makes it possible to use Notes/Domino from modern C# without Java, JNA, or JNX dependencies. The library currently provides support for:

  • Sessions and databases
  • Documents and views
  • ACL access
  • MIME entities and MIME headers
  • Rich text
  • Document signing
  • Database directory enumeration
  • Native lifecycle management through IDisposable and Recycle()

The project is still under development, but the core object model and native interop layer are in place.

And a special thanks to the authors and contributors of
https://github.com/HCL-TECH-SOFTWARE/domino-jnx
And Karstens JNA Project
https://github.com/klehmann/domino-jna

Leave a Comment


NOTE - You can use these HTML tags and attributes:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>

This site uses Akismet to reduce spam. Learn how your comment data is processed.