1
votes

I'm using the Domino .NET wrapper classes to allow users to drag an email from their Lotus inbox to a winform.

I'm getting a data object back, that contains notes URL to the document, in the form

notes://server/replicaID/viewID/documentUNID

And passing it to Domino.NotesSession.Resolve(pUrl) which is supposed to return the matching document. Actually, pasting the link in my browser (replacing notes:// by http:// works like a charm, I get the HTML version of the email) works.

But the Resolve method keeps on returning what seems to be a NotesView, not the actual document :

Dim notesSession as Domino.NotesSession = ' ...  Initialize session here
Dim notesURL as string = "notes://server/replicaID/viewId/documentID"

Dim draggedDocument = notesSession.Resolve(notesURL)
' Here, I do get an actual document, but its UnID matches the viewId 
' part of the url, not the document.

I tried removing the viewID from the URL, but with no more success. The only way I found to successfully retrieve the document is by using the OLE objects (lotus namespace) :

' Get UnId from url
Dim unid as String = notesURL.Split("/").Last()

' Get UI Automation object
Dim workspace = CreateObject("Notes.NotesUIWorkspace")
' Get currently open DB (the where the drag event was initiated)
Dim notesDb = workspace.CURRENTDATABASE.Database
' Retrieve matching document
Dim notesDoc = notesDb.GetDocumentByUNID(unid)

While this method works, I don't want to use the UI automation classes (OLE), but Domino's COM wrapper (.NET).

So how do exactly these notes URLs work in interop ? Is there any way I can retrieve the matching document without knowing the database first hand ? Why does the Resolve method return a view object when given a document URL ?

Any help welcome.

2

2 Answers

2
votes

It sounds like you're dealing with a bug in the Resolve method. But your second idea seems like a reasonable workaround. I don't see the need to make the call to CreateObject, though. The wrapper classes should work fine.

You have the NotesSession in the first code sample (the Domino.NotesSession object) so you should be able to call the Resolve method on it to retrieve the database object based on the NotesUrl you have. You don't need to get the view, necessarily, just the database object. From that object, you can then call the GetDocumentByUNID method to retrieve the document you want. It would be nice if the Resolve method did that for you, but it sounds like it gets you close enough.

Dim notesSession as Domino.NotesSession =  <Session>
Dim notesURL as string = "notes://server/replicaID"    
Dim notesDocUNID as string = "parse URL to get the UNID"

Dim notesDatabase = notesSession.Resolve(notesURL)
Dim document = notesDatabase.GetDocumentByUNID(notesDocUNID)
0
votes

Session.resolve doesn't return a NotesDocument. It returns a generic object (off my head I would say Base - the base class of all Notes data objects). You have to dim your variable accordingly then check the type and cast it into a document