<p>In particular, I have to extract all the messages and attachments from Lotus Notes files in the fastest and most reliable way. Another point that may be relevant is that I need to do this from a secondary thread.</p>

<p><strong>Edit</strong></p>

<p>Thanks for the answers - both of which are good. I should provide more background information. </p>

<p>We currently have a WinForms application with a background thread using the Notes COM API. </p>

<p>However it seems to be unstable. (Of course it may be we are doing something wrong.) For example, we have found we have to preinitialize the Notes session on the main thread or else the call to session.CreateDXLExporter() on the background thread throws an exception.</p>

[{'answer_id': 45143, 'author': 'Joshua Turner', 'author_id': 820, 'author_profile': 'https://Stackoverflow.com/users/820', 'pm_score': 2, 'selected': False, 'text': '<p>Take a look at NotesSQL:<br/></p>\n\n<p><a href="http://www.ibm.com/developerworks/lotus/products/notesdomino/notessql/" rel="nofollow noreferrer">http://www.ibm.com/developerworks/lotus/products/notesdomino/notessql/</a></p>\n'}, {'answer_id': 50736, 'author': 'Jeff Bonnes', 'author_id': 5286, 'author_profile': 'https://Stackoverflow.com/users/5286', 'pm_score': 2, 'selected': False, 'text': "<p>If you have a Domino / Lotus Notes client installed on the same machine, you can use COM.  Just do a Google search on 'Accessing the Domino Objects through COM' and you'll find the Domino Designer help entry for just about any version of Domino.</p>\n\n<p>You can also access Domino via the C API, but wouldn't recommend it.  Very messy.  You also still need the Domino / Lotus Notes client installed.</p>\n\n<p>If you do <em>not</em> have Domino / Lotus Notes client installed on the same machine and the Domino server is running http, you could also do it via http.  This will not be nearly as fast.  You would also probably want some custom http views setup on the Domino server to make your life easier.</p>\n"}, {'answer_id': 71910, 'author': 'Eric Labashosky', 'author_id': 6522, 'author_profile': 'https://Stackoverflow.com/users/6522', 'pm_score': 2, 'selected': False, 'text': '<p>You could create a Domino web service using Java or LotusScript.  Then use C# to access the web service.  </p>\n\n<p>I\'ve only done this once, to read data out of an Lotus Notes db into a .NET app running on another machine.</p>\n\n<p>Writing and testing simple Web services\n<a href="http://www.ibm.com/developerworks/lotus/library/web-services2/" rel="nofollow noreferrer">http://www.ibm.com/developerworks/lotus/library/web-services2/</a></p>\n\n<p>when i find some time I will write a complete example  :-)</p>\n'}, {'answer_id': 122932, 'author': 'Sam Schutte', 'author_id': 146, 'author_profile': 'https://Stackoverflow.com/users/146', 'pm_score': 1, 'selected': False, 'text': "<p>I worked on a Notes plugin for several months a little while back, and yes, the API can be maddening.  However, I was able to get it to work so I could access all the Notes information using a C# application (actually, since I was writing a plugin, I had Notes call out to the C# app through a C++ bridge that it registered in a startup .ini file).  Certain methods that they document in their API don't actually work though, so a lot of testing is required.  Sometimes you have to do some code gymnastics...</p>\n"}, {'answer_id': 226491, 'author': 'GvS', 'author_id': 11492, 'author_profile': 'https://Stackoverflow.com/users/11492', 'pm_score': 2, 'selected': False, 'text': '<p>An Lotus Notes COM Api Reference can be found <a href="http://www-12.lotus.com/ldd/doc/lotusscript/lotusscript.nsf" rel="nofollow noreferrer">here</a></p>\n\n<p>To get a Notes Session (The starting point) in VB.Net you can use:</p>\n\n<pre><code>Dim oSess As Object = Nothing\noSess = CreateObject("Notes.NotesSession")\n</code></pre>\n\n<p>I normally program in C#, for operating with COM I prefer VB.Net</p>\n\n<p>It is better to access all COM servers from the same thread, unless you are certain that is will not cause any trouble.</p>\n'}, {'answer_id': 388823, 'author': 'Peter T. LaComb Jr.', 'author_id': 8513, 'author_profile': 'https://Stackoverflow.com/users/8513', 'pm_score': 1, 'selected': False, 'text': '<p>Back in the day I would have recommended N2N from Proposion, but that product has gone since Quest acquired Proposion.</p>\n\n<p>That said, Proposion was proof that you can wrap the Notes API in a set of .Net classes safely. You can find some info on that in <a href="http://www.bobzblog.com/tuxedoguy.nsf/dx/calling-notes-capi-from-cvisual-studio?opendocument&amp;comments" rel="nofollow noreferrer">Bob Balaban\'s blog</a>.</p>\n'}, {'answer_id': 1313209, 'author': 'Martin Murphy', 'author_id': 85353, 'author_profile': 'https://Stackoverflow.com/users/85353', 'pm_score': 0, 'selected': False, 'text': '<p>I would personally do this native in Notes in either LotusScript or Java.  You can do a scheduled agent in Notes much easier than a service in C#.</p>\n'}, {'answer_id': 3267347, 'author': 'Alex Rouillard', 'author_id': 274879, 'author_profile': 'https://Stackoverflow.com/users/274879', 'pm_score': 3, 'selected': False, 'text': '<p>I really do hate that NotesSession COM object.</p>\n\n<p>You cannot use it in another thread than the thread it was initialized.\nThreads in .NET are fibers, the real underlying thread may change at any time.</p>\n\n<p>So I suggest using it this way, in a <em>using</em> block :</p>\n\n<pre><code>Imports Domino\nImports System.Threading\n\nPublic Class AffinitedSession\n    Implements IDisposable\n\n    Private _session As NotesSession\n    Public Sub New(ByVal pass As String)\n        Thread.BeginThreadAffinity()\n        _session = New NotesSession()\n        _session.Initialize(pass)\n    End Sub\n\n    Public ReadOnly Property NotesSession() As NotesSession\n        Get\n            Return _session\n        End Get\n    End Property\n\n    Private disposedValue As Boolean = False        \' To detect redundant calls\n\n    \' IDisposable\n    Protected Overridable Sub Dispose(ByVal disposing As Boolean)\n        If Not Me.disposedValue Then\n            If disposing Then\n                \' TODO: free other state (managed objects).\n            End If\n\n            \' TODO: free your own state (unmanaged objects).\n            \' TODO: set large fields to null.\n            _session = Nothing\n            Thread.EndThreadAffinity()\n        End If\n        Me.disposedValue = True\n    End Sub\n\n#Region " IDisposable Support "\n    \' This code added by Visual Basic to correctly implement the disposable pattern.\n    Public Sub Dispose() Implements IDisposable.Dispose\n        \' Do not change this code.  Put cleanup code in Dispose(ByVal disposing As Boolean) above.\n        Dispose(True)\n        GC.SuppressFinalize(Me)\n    End Sub\n#End Region\n\nEnd Class\n</code></pre>\n\n<p>Notice the Thread.BeginThreadAffinity() and the Thread.EndThreadAffinity()</p>\n\n<p>Those are your friends.</p>\n\n<p>Cheers !</p>\n'}, {'answer_id': 3995664, 'author': 'Alexey Zimarev', 'author_id': 484041, 'author_profile': 'https://Stackoverflow.com/users/484041', 'pm_score': 0, 'selected': False, 'text': "<p>I personally quite like Domino wrapped .NET assembly for COM API. When you develop your C# code you almost can imagine your dreams about a proper Notes IDE became true. But it has some drawbacks like for the version 6.5 (I haven't tried newer) you get your application crashes in many cases when the LotusScript code returns type mismatch for the parameter. But this is due to COM limitations of course.</p>\n\n<p>At the same time the wrapper doesn't allow working with NotesUI classes. However I used reflections from very old Notes COM API examples to call NotesUI classes and it worked. It was handy when I developed an Outlook plug-in that required interaction with Notes client UI. I managed to create a simple wrapper for UI classes too.</p>\n"}, {'answer_id': 36516796, 'author': 'Brien Halstead', 'author_id': 4709365, 'author_profile': 'https://Stackoverflow.com/users/4709365', 'pm_score': 1, 'selected': False, 'text': '<p>I know this thread is old, but I\'ve worked a lot with the Domino API and the typical Notes LotusScript objects via the Domino COM API.</p>\n\n<p>The problem with the Domino API is that its memory management via COM is horrible (if using the API in C#, or VB, etc.), and it will cause memory leaks and eventually cause the whole API and the Notes client to crash (even if you don\'t have the client open, you will not be able to start it after the API crashes without restarting your computer, or calling "nsd -kill"). Fun.</p>\n\n<p>I\'ve found that using the Notes C API within C# via P/Invoke, you can better manage the memory resources so that the API doesn\'t cause horrible memory leaks and crashes. I wrote a partial wrapper in C#, using P/Invoke, that accesses the Notes C API from the notes.dll. My use of it has nothing to do with trying to work within a Domino environment, but to make use of the Notes assembly to have access to NSF files to extract DXL information within a C# environment. Obviously, you would need to have the Notes client installed to have access to the notes.dll and the C API. But my C# wrapper of the Notes C API works great and is more stable than the Domino COM API that is provided when you install the Notes client.</p>\n\n<p>The classes that I\'ve implemented in C# (that I\'ve only needed) from the Notes C API are:</p>\n\n<p>NotesSession (as NotesRuntime)\nNotesDatabase\nNotesNote\nNotesItem\nNotesDXLExporter\nNotesNoteCollection</p>\n\n<p>As well as some other interim classes, enums, and structs to handle the translation from the C API into C#.</p>\n\n<p>The classes I\'ve implemented thus far have served the purposes that I\'ve needed from the Notes C API. They can definitely be expanded upon, but I didn\'t try to encapsulate the entire API within the C# P/Invoke wrapper. I also had to create handlers for dealing with OLE embedded objects that may be stored within Notes documents, and getting the stored data out of those OLE objects, using Windows IStorage objects.</p>\n\n<p>Note: I can provide some samples later (I have to rename namespaces and generalize the code, due to proprietary reasons), but I created the C# wrapper classes by using the "Lotus C API Notes/Domino 8.5.2 Reference" NSF that is provided by IBM/Lotus (as a downloadable NSF). Using the C definitions and class references, I could translate those to C# P/Invoke calls and wrap them into friendlier C# classes, that then behaved more like LotusScript class calls, but within C#, and the implemented classes manage and dispose of their memory so that the whole thing doesn\'t crash after you\'ve accessed hundreds of thousands of documents from a C# program. :)</p>\n'}]
['https://Stackoverflow.com/questions/45132', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/1899/']