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);
}
}
}
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);
}
}
}