المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Multithread email reader!!!



C# Programming
11-10-2009, 01:50 PM
Hi Dear all.

I`m not a C# programmer , but I manage to make a little email Pop3 reader searching in the internet. This program has a timer and every 5 min looks into an email account and read and download some information. Now what I need is the possibility to read mails from more than one email account at the same time. IE, if I have two Gmail account, the program should look into this two account every 5 min and download the info I need. Please, anyone that help me on this. I´m using Higuchi.net lib for connecting to email accounts, it´s a very good one, anybody can google it and download it, it is free. I have tried multithreading but with no luck. My code is the following:

public partial class Pop3 : Form
{
public Pop3()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
if (this.checkBox2.Checked != true && this.checkBox3.Checked != true && this.checkBox1.Checked != true)
{
MessageBox.Show("Select a Conection Option");
}
else
{
timer1.Tick += new System.EventHandler(this.OnTimerTick);
timer1.Enabled = true;
timer1.Start();
this.button1.Enabled = false;
}
}

private void OnTimerTick(object sender, EventArgs e)
{

if (this.checkBox2.Checked == true)
Gmail();

if (this.checkBox3.Checked == true)
Gmail2();

if (timer1.Interval != 360000)
timer1.Interval = 360000;
}


private void Gmail()
{
Pop3Client cl = new Pop3Client();
cl.UserName = "xxxxxxxxx@gmail.com";
cl.Password = "xxxxxxxxx";
cl.ServerName = "pop.gmail.com";
cl.Port = 995;
cl.AuthenticateMode = Pop3AuthenticateMode.Pop;
cl.Ssl = true;
cl.Authenticate();

if (cl.Available == true)
{
if (cl.ReceiveTimeout = 1)
{
try
{
int ncount = Convert.ToInt32(cl.GetTotalMessageCount());
for (int i = 1; i