问题
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:
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.
回答2:
Solution is:
Object[] docColl = _notesDatabase.Views as Object[];
foreach (Object objView in docColl) {
NotesView view = objView as NotesView;
MessageBox.Show(view.Name);
}
回答3:
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
来源:https://stackoverflow.com/questions/1357612/how-to-get-list-of-views-from-mail-in-lotus-notes-using-net