tags:

views:

389

answers:

3

I am accessing mail from Lotus notes.

And in order to access "Inbox" i am using below code:

_notesDatabase = _lotusNotesServerSession.GetDatabase(LotusNotesServer, "mail\\" + nsfName, false);
NotesView inbox = _notesDatabase.GetView("($Inbox)");

Similarly for "Drafts".

But here i am specifying name of each view in GetView method. Which is not good coding.

I want to list these views "Inbox","Drafts" programaticaly using C#.

Can anybody give me solution?

+1  A: 

There is a property of the NotesDatabase class called Views that will let you access all the views in the database. You could loop through them to access each view.

Also this open source class called DatabaseProperties can help you get a list of design documents, specifically the views in the database, and many more of the view's properties.

Ken Pespisa
_notesDatabase = _lotusNotesServerSession.GetDatabase(LotusNotesServer, "mail\" + nsfName, false); after this i am using _notesDatabase.views();I am new to C#.I am enable to display it's value.Can you help me out in this?
Preeti Singh
I got solution.Thanx Ken.
Preeti Singh
A: 

In VB.net, the basic code to get all views (and folders) and for each, to get all included documents, would look something like this:

Dim s As New notesSession
Dim db As notesDatabase
Set db = s.CurrentDatabase
Dim vws As Variant
vws = db.Views
Forall v In vws
 'New View being processed
 Dim doc As notesDocument
 Set doc = v.getFirstDocument()
 While Not (doc Is Nothing)
  ' do something for each document
  ' ....
  Set doc = v.getNextDocument(doc)
 Wend
End Forall
Ed Schembor
A: 

Solution is:

Object[] docColl = _notesDatabase.Views as Object[];

foreach (Object objView in docColl) {  
   NotesView view = objView as NotesView;
   MessageBox.Show(view.Name);    
}
Preeti Singh