Wednesday, July 11, 2012

Reading a Lotus Notes Mail Box



You need the Lotus Domino Objects to be added into your application. Refer: http://www.ibm.com/developerworks/lotus/library/domino-msnet/

You need to know the Path of your Lotus Notes Mail-box:

 
Domino.NotesSession s = new Domino.NotesSession();
            Domino.NotesDatabase db;
            Domino.NotesView vw;
            Domino.NotesDocument doc;

            try
            {
                //Leave blank Password, then It will prompt for Password, It basically authenticates with the *.id file
                s.Initialize("mypassword");

                //If Server is blank, which Local otherwise specify the Server
                //Place the Mailbox path Next
                db = s.GetDatabase("", @"C:\Documents and Settings\me\Local Settings\Application Data\Lotus\Notes\Data\mail\me\mymailbox.nsf", false);
                if (db != null)
                {
                    //Inbox is special/hidden folder
                    vw = db.GetView("($Inbox)");
                    doc = vw.GetFirstDocument();

                    while (doc != null)
                    {
                        String Subject = ((object[])doc.GetItemValue("Subject"))[0] as String;
                        String From = ((object[])doc.GetItemValue("From"))[0] as String;

                        textBox1.Text += Subject;
                        textBox1.Text += From;
                        doc = vw.GetNextDocument(doc);
                    }
                }
            }
            catch (Exception er)
            {
                MessageBox.Show(er.Message);
            }
 
 
Additional Resources:









MODI Viewer

It appears that MODI (Microsoft Office Document and Imaging) Viewer control does not release the previous file if a new file to be swapped; I had facing the same trouble when I tried to open a new ".tif" file after the previous was viewed. Note here is that I use the same file name for view and delete it and finally if a new file is been given I rename it back for any new to the same file name which I had deleted.

Check how I overcame it here

An article I got while googling on the same topic can be seen here

Good Luck!