0

DocumentCollection documents = db.getAllDocuments(); Document doc = collection.getFirstDocument();

Which method used to identify the document Location. Whether it is in Inbox or Sent or Drafts.

Anand Murugan
  • 767
  • 2
  • 7
  • 12

4 Answers4

1

The safest way is to get a handle to each folder using db.GetView() and then look to see if the document is within that folder. For that you could use the db.AllEntries() method to get a NotesViewEntryCollection, and then call the GetEntry method to see if the document is within that collection.

If you have folder references enabled for the database, you might be able to use the folderreferences property of the Notes Document to make things easier.

Ken Pespisa
  • 21,989
  • 3
  • 55
  • 63
  • Hi Ken, I have tried with your idea by getting the View using db.getView() View notesView = (View) db.getView("$Sent"); ViewEntryCollection notesViewCollections = notesView.getAllEntries(); ` – Anand Murugan Mar 22 '12 at 07:26
1

Inbox is a folder. Sent and Drafts are views. Here's an approach which will work the same way for both views and folders:

  • Use View myView = Database.getView to get either the ($Inbox), ($Sent) or ($Drafts) view.
  • Create an empty NoteCollection object
  • Use NoteCollection.add(doc) to put your document into the collection
  • Then use NoteCollection.intersect(myView).
  • If NotesCollection.Count !=0, your document is still in the NoteCollection, therefore it was in the view or folder that you are testing.
Richard Schwartz
  • 14,463
  • 2
  • 23
  • 41
  • Further background... Sent messages have a PostedDate item and no DeliveredDate item. $Sent is a view, with this selection formula SELECT DeliveredDate = "" & PostedDate != "" & !(@IsMember("S"; ExcludeFromView)); so all messages with a valid PostedDate and no DeliveredDate are in the Sent folder unless they contain "S" in the ExcludeFromView item. – Richard Schwartz Mar 21 '12 at 16:04
  • Sent messages have a PostedDate item and no DeliveredDate item. $Sent is a view, with this selection formula SELECT DeliveredDate = "" & PostedDate != "" & !(@IsMember("S"; ExcludeFromView)); so all messages with a valid PostedDate and no DeliveredDate are in the Sent folder unless they contain "S" in the ExcludeFromView item. – Richard Schwartz Mar 21 '12 at 16:05
  • For both Sent and Drafts, if you don't want to use the NoteCollection approach, you can either directly code the tests for the appropriate items, or you can use these formulas with the Session.Evaluate method and get the result. Inbox is a different story, because it is a folder not a view. Received messages have a valid DeliveredDate item, so you could check for that -- but not all received messages are in Inbox because users can move them to other folders. So if you don't want to use the NoteCollection approach, then follow Ken's advice and check every Entry in the ViewEntryCollection. – Richard Schwartz Mar 21 '12 at 16:07
  • Thank you rhsatrhs... I have tried with Ken's approach and use the code sample of guilio.. It is working fine for me.... – Anand Murugan Mar 22 '12 at 07:39
1

This problem involves 2 aspects. Folders and views. You can accomplish in two parts. Firstly, you can check this IBM technote that addresses your question in relation to folders (ie Inbox is a folder).

The "Draft" and "Sent" design elements are views, and therefore must be searched differently. You can accomplish this by using the "contains" method of the NotesViewEntryCollection like so:

Function FindDocument(view As notesView, doc As notesDocument) As Boolean
    On Error Goto errHandle
    Dim vec As NotesViewEntryCollection
    Dim bFound As Boolean

    bFound = False
    Set vec = view.AllEntries
    If vec.Contains(doc) Then
        bFound = True
    End If
    FindDocument = bFound
    Exit Function
errHandle:
    Print Lsi_info(2) + ":" + Str(Err) + " - " + Error(Err) + _
    ", at line " + Str(Erl)
    Exit Function
End Function

Note that you can use this function for any view not just sent/draft views.

angryITguy
  • 9,332
  • 8
  • 54
  • 82
  • Hi giulio, Thank you for your great help.. I have tried this with java... It is working properly... I got the correct results.. Thank you all.. – Anand Murugan Mar 22 '12 at 07:15
0

Open the mail database in the Domino Designer and look at the views and folders. If it's a view there is a Select statement, see what documents are selected. If it's a folder, you have to know how documents are attached to the folder.

($Sent) is a view, but ($Drafts) and ($Inbox) are folders. For the latter two, you indeed have to use FolderReferences.

D.Bugger
  • 2,300
  • 15
  • 19