Accessing outlook express

Joined
Apr 23, 2009
Messages
1
Reaction score
0
aftre reading 120 mail frm outlook it shows Error can any 1 tell me the reason??

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Microsoft.Office.Interop.Outlook;

namespace started
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}



private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{

}

private void textBox1_TextChanged(object sender, EventArgs e)
{

}


private void button1_Click(object sender, EventArgs e)
{
// MessageBox.Show("came here1212121");

int i;
int j;
int m = 0;

do
{

Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.ApplicationClass();
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
i = myInbox.Items.Count;
j = Int32.Parse(textBox1.Text);
int k = 0;
k=i - j;
string message = "";
message = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[k]).SenderName;
((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[k]).SenderName;
message = message + " " + ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[k]).CreationTime.ToString();
((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[k]).SenderName;
listBox1.Items.Add(message); listBox1.Items.Add(((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[k]).Subject);
message = "";
j = j + 1;
textBox1.Text = j.ToString();
} while ((i - j )> 0);

}

}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top