How to use formula language to query only inbox message with specific range

Hello.

I have a requirement to create a Java program to query inbox message of a user with specific range. Currently, I use API to query to {$Inbox} view, then use getAllEntriesByKey() method specifying DateRange object of the range to query. For example

===============================

String ior = NotesFactory.getIOR(host);

Session s = NotesFactory.createSessionWithIOR(ior, username, password);

Database db = s.getDatabase(“”, “mail/aadmin.nsf”);

View view = db.getView(“($Inbox)”);

DateTime begin = s.createDateTime(dateFormat.parse(“2005-01-01 00:00:00”));

DateTime end = s.createDateTime(dateFormat.parse(“2005-12-30 23:59:59”));

DateRange dateRange = s.createDateRange(begin, end);

ViewEntryCollection c = view.getAllEntriesByKey(dateRange);

===============================

This code has been working fine because {@Inbox} view is sorted by date column with match the parameter passes in to getAllEntriesByKey method.

But soon our Lotus Domino backend will be upgraded to 6.5 and custom mail template is going to be used which the column not sorted by date anymore. This will break our current code since parameter to getAllEntriesByKey has to match the sorted column.

The solution I am thinking is to query directly to user database without using view, but use formula language instead (use Database.search()). I come up with this query

==============================

"DeliveredDate != “”

& PostedDate > @Date(2003; 01; 01; 11; 05; 00)

& PostedDate < @Date(2006; 06; 17; 11; 30; 00)

==============================

I figured out that only incoming mail will have “DeliveredDate” property set, and the property which is shown in Date column in Lotus Notes is “PostedDate”. Is this correct?

The problem I am having here is with this query I will get all incoming mail in specified range, from all folder, NOT just from inbox. Is there anything I can add to this query to filter only incoming mail which is in “Inbox” folder only?

Thank you very much in advanced.

Tinnapat Chaipanich

Software Engineer

PWS Consulting Co., Ltd

Email: tinnapat.c@pwsconsulting.com

Subject: How to use formula language to query only inbox message with specific range

I’m not aware of any formula that will allow you to filter on a specific folder.

I suspect all you will be able to do is grab all the documents that meet your search criteria, then test each document in turn to see if it is a member of the $InBox folder, before further processing.

For example:

Set view = db.GetView(“$Inbox”)

…

'Loop through docs

…

viewNav = notesView.CreateViewNavFrom(doc)

if viewNav.count > 0 then

'document is in InBox…

HTH - Rufus.

Subject: RE: How to use formula language to query only inbox message with specific range

It would probably be faster to just use the viewenteries in $Inbox and test the column values. You can get the right column by checking the columns collection of the view for the item each column represents, so your code doesn’t have to depend on the received date being in a specific column – as long as the column is in the view, you can get the corresponding column number and use it is the ColumnValues call as you walk the view.

Subject: RE: How to use formula language to query only inbox message with specific range

Hello Stan

First of all, thank you very much for your valuable suggestion.

I have consider 2 alternatives, which are.

  1. Get all documents matched the criteria, then test each one if it is in inbox.

  2. Get all documents from ($Inbox) view, then test each one if it matchs the criteria.

These 2 solutions would work, but what I concern here is the performance if the user have a lot of email documents. Lotus Domino in our environment is quite slow too when we talk to it remotely.

What we do here is a kind of adapter which connect a front-end application to back-end Lotus Domino server. If there is no straighforward way to achieve this, maybe I will check with my client whether it is OK if they will see all incoming mails, regardless what folder they are in.

Subject: RE: How to use formula language to query only inbox message with specific range

If you use the column values rather than the document items, the search can be pretty fast.

Subject: RE: How to use formula language to query only inbox message with specific range

Ok, i see. I will try it. Thanks you very much for your comment.