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:









No comments: