How to access contents of Folders created by user in Lotus Notes Using .NET?
-
05-07-2019 - |
Question
I am getting contents of all views (Folders).Like Inbox,Calendar,ToDo e.t.c.
As mentioned in Title i want to access contents of Folders created my user. For Example "Folder1" and sub-folder "ABC"
I can do it as:
NotesView folder = _notesDatabase.GetView("(Folder1)");
NotesDocument docFolder = folder.GetFirstDocument();
For sub-folder : NotesView folder = _notesDatabase.GetView("(Folder1/ABC)");
But here i need to specify folder name.Which can't be known in advance. So i can't hard code it.
Is there any way to get only list of User created Folders and Sub-folders?
Solution
To iterate over all folders in a mailbox, use NotesDatabase.Views
and the isFolder
property. Then you can either explicitly exclude ($Inbox), ($Junkmail) et.c. or use the heuristic that folders where the name begins with "(" are system folders:
Dim session As New notessession
Forall fa_view In session.currentdatabase.views
If fa_view.isFolder() Then
If Left$(fa_view.name,1) <> "(" Then Print fa_view.name
End If
End Forall
Ken Pespisas suggestion to use isPrivate
is nicer and will work unless users are allowed to create shared folders. I'm not sure if this is the default Notes access or not.
OTHER TIPS
You can get a collection of views using the NotesDatabase Views property
_notesDatabase.Views
If you loop through that collection, you can inspect each view's IsPrivate property to see if it is a private view created by the user. In Lotusscript it would look like this
Dim allViews as Variant
Set allViews = _notesDatabase.Views
ForAll myview In allViews
If myview.IsPrivate Then
'Do something
End If
End ForAll