Question

I am working on a simple Java code to extract all calendar entries for a given date. I know it's possible using Domingo but I would like to use only Notes.jar for this purpose. It is possible for me to create a session based on a given credentials and get the calendar object. I am looking to extract the current running Notes session and use that session object to open the calendar view in the mail file and start playing with it. But I am not able to get it working. Anybody have any idea or links on this?

Was it helpful?

Solution

Well I have done with the default notes API and here's the code.

NotesAPITest nat = new NotesAPITest();
        NotesThread.sinitThread();

        Session sess1 = NotesFactory.createSession();
        System.out.println(sess1.getUserName());
        Database database = sess1.getDatabase("", "mailfile");
        View calendarView = database.getView("($Calendar)");
        DateTime dt = sess1.createDateTime("today");
        ViewEntryCollection vec = calendarView.getAllEntriesByKey(dt, true);

        ViewEntry entry = vec.getFirstEntry();
         while (entry != null) 
         {

           Document caldoc = entry.getDocument();

           System.out.println("Subject: " + caldoc.getItemValueString("Subject"));
           System.out.println("Chair Person: " + caldoc.getItemValueString("Chair"));
           System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "StartDateTime") );
           System.out.println("Start Time: " + nat.getStartEndTimes(caldoc, "EndDateTime") );
           System.out.println("Required: " + caldoc.getItemValueString("RequiredAttendees"));
           entry = vec.getNextEntry(); 
         }  

The only drawback i see is that, whenever the session is extracte, notes pops up a password dialog box. In my searches so far I have not seen a solution for that. Apparently a security arrangement in LN i guess.

OTHER TIPS

Just by googling I have found this article. They create an Eclispe plugin there for Notes. And the example code for getting employee brithdays is also there (I guess Calendar works in a similar way):

    s = NotesFactory.createSession();

    // Get the local address book
    Database nab = s.getDatabase("",s.getAddressBooks().elementAt(0).toString());
    if (nab.isOpen() == false) nab.open();  

    // Get the Birthdays & Anniversaries view           
    View baview = nab.getView("BA");
    ViewEntryCollection eba = baview.getAllEntries();
    ViewEntry entry = eba.getFirstEntry();

    list = new String[eba.getCount()];
    int count = 0;

    while (entry != null) {

        Vector vals = entry.getColumnValues();                           
        list[count]= vals.elementAt(1).toString() + " " + vals.elementAt(2).toString();                         
        entry = eba.getNextEntry();
        count++;
    }

EDIT: Also look at this link for some documentation on Notes.jar.

The NotesFactory.createSession() method is what you can use to get a handle to the current session. Notes will automatically share the current client session. If this method is failing, there may be something wrong with your basic configuration. Be sure that:

  • You have the Notes Client fully installed on the machine running the Java app, and be sure there is a valid Notes ID file. (For example, be sure you can open the Notes client on this machine successfully).
  • Also, be sure that the the nnotes.dll file is accessible on your machine's path (different than the Java CLASSPATH).
  • And, confirm that the Notes.ini file is also on the machine's PATH.

@vikramjb, try doing NotesFactory.createSession((String) null, (String) null, password); to prevent the notes password popup from prompting you each time you do something with the session that needs security.

Found out about this from here: http://lekkimworld.com/2006/07/10/java_in_notes_domino_explained_domino_session_tester.html

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top