I did that once.
You have to add a new reference to your project and choose COM in the Add Reference dialog. Find the component named Lotus Domino Objects in the list and add it. You will see a new reference called Domino added to your project. That COM component is installed by the Lotus Notes Client. You must have it in your development machine, and you will have to have it installed when you run your application too.
From that point you can use most of the classes you have available when developing with lotusscript within NotesDesigner.
Add an appropriate using statement:
using Domino;
Create a notes session:
NotesSession session = new NotesSession();
session.Initialize("mypassword");
//this uses your current Notes location and id.
//i think you can use session.Initialize("") if notes is already running and you are already logged in.
Get a database:
NotesDatabase notesDb = session.GetDatabase("server", "database", false);
Get some documents, for example: today s appointments (if the database you opened is your mail.nsf)
NotesDocumentCollection col = null;
try { col = notesDb.Search("Form = "Appointment" & StartDate = @Today", null, 0); }
catch (Exception e) { }
Iterate through your collection:
if (null != col)
{
NotesDocument doc = col.GetFirstDocument();
while (doc != null)
{
//do your magic tricks
doc = col.GetNextDocument(doc);
}
}
One problem I noticed with this interface: there is no session.Close() method nor anything similar, and my sessions were not being closed in the server once the GC collected the C# object. Once I opened a new NotesSession(), it stayed alive in the domino server as long as my c# thread was alive. To solve that problem, I had to create background threads and only instantiate new NotesSession() objects from within the threads. The threads also had to be setup with STA apartment mode before being started.
Thread thread = new Thread(new ThreadStart(MyFunctionThatInstantiatesNewNotesSessions));
thread.SetApartmentState(System.Threading.ApartmentState.STA);
thread.Start();
thread.Join();
I m not sure if this problem is really a problem in the interface, or something else i did wrong in my code. But if someone is facing that problem: threads are the way I fixed it.