1

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.

T. Fabre
  • 1,517
  • 14
  • 20

2 Answers2

2

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)
Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
  • Actually, I retyped the second sample and made a mistake : it was CreateObject("Notes.NotesUIWorkspace"), but I guess your point is still correct. Thanks for your insight :) – T. Fabre Jul 06 '12 at 15:13
  • Small clarification on terminology: The Domino.NotesSession is a COM class underneath the Interop layer. The Notes.NotesUIWorkspace is an OLE class for, as you said, UI Automation. One more thing: You said you tried removing the view component from the URL, but did you try replacing it with '0', as in notes://server/replicaID/0/documentUNID? – Richard Schwartz Jul 06 '12 at 15:35
  • OK, sorry for the confusion, I fixed it in the question. I tried replacing the view ID by 0 as you suggested : it returns the database object instead. Since I can't do without parsing the URL, I'll go with Ken Pespisa's method. – T. Fabre Jul 06 '12 at 17:46
0

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

stwissel
  • 20,110
  • 6
  • 54
  • 101