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!

Tuesday, May 22, 2012

Having Text and Image in One Single Column of DataGridView


DataGridView's Cell_Painting event could be utilized to achieve the above. You need a DataGridView and ImageList in which an Image to be attached. The following simple code in event will be able to achieve this:

private void dataGridView1_CellPainting(object sender, DataGridViewCellPaintingEventArgs e)
 {

    if (e.RowIndex >= 0 && e.ColumnIndex == 0 && Convert.ToInt32(e.Value.ToString()) > 0)
    {
        e.PaintBackground(e.ClipBounds, false);
       dataGridView1[e.ColumnIndex, e.RowIndex].ToolTipText = e.Value.ToString();
       PointF p = e.CellBounds.Location;
       p.X += imageList1.ImageSize.Width;

      e.Graphics.DrawImage(imageList1.Images[0], e.CellBounds.X, e.CellBounds.Y, 16, 16);
       e.Graphics.DrawString(e.Value.ToString(), e.CellStyle.Font, Brushes.Black, p);
       e.Handled = true;
    }

}
 
Refer DataGridView FAQ in the following Thread:
http://social.msdn.microsoft.com/Forums/en-US/winformsdatacontrols/thread/b5ab78d6-a760-4f29-ac89-46bad51ba30a







Installing the Visual Studio 2005 Image Library

The Visual Studio 2005 Image Library is copied to your computer when you install Visual Studio. To access the files in the image library, you must extract them from the file VS2005ImageLibrary.zip.

To install the Visual Studio 2005 Image Library

  1. Locate the file VS2005ImageLibrary.zip. This file is normally installed in \...\Program Files\Microsoft Visual Studio 8\Common7\VS2005ImageLibrary\.
  2. Right-click VS2005ImageLibrary.zip and click Extract All.
    The Extraction Wizard appears.
  3. Follow the directions in the wizard to extract the images.
Refer MSDN Link

Thursday, February 02, 2012

How to configure OracleXEClient to connect to OracleXE?

1. Create a new user Variable called “TNS_ADMIN”
Assume ORACLE_HOME of XE is in C:\oracle\product\oraclexe
Since when you install Oracle 10g Express Edition, a tnsnames.ora file has already been created for you in C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
Either set TNS_ADMIN in DOS prompt or in a New User Variable
You can set TNS_ADMIN to your local path of Oracle Express Database
set TNS_ADMIN= C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora
or you can copy tnsnames.ora from C:\oracle\product\oraclexe\app\oracle\product\10.2.0\server\NETWORK\ADMIN\tnsnames.ora to C:\oracle\product\XEClient, and set TNS_ADMIN in the User Variable

Click on [Start], Programs, Oracle Client 10g Express Edition, Run SQL Command Line
SQL> connect sys/ora10g_manager@xe as sysdba

Other ways to connect to Oracle Express in DOS prompt

Method 1:
Set TNS_ADMIN in DOS prompt
In DOS prompt,
C:\> set TNS_ADMIN=C:\oracle\product\XEClient
C:\> C:\oracle\product\XEClient\bin\sqlplus.exe /nolog
SQL> connect sys/ora10g_manager@XE as sysdba

Method 2:
No need to set TNS_ADMIN in DOS prompt but enter the full connection string in one line of DOS command
Set NLS_LANG in DOS Prompt
C:\>set NLS_LANG=English
Enter the following DOS command all in ONE line
C:\>sqlplus "sys/ora10g_manager@(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))(CONNECT_DATA=(SERVICE_NAME=XE))) as sysdba

Source: https://forums.oracle.com/forums/thread.jspa?threadID=576930