Pop3Client pop3Client;
if (Session["Pop3Client"] == null)
{
pop3Client = new Pop3Client();
pop3Client.Connect(txtMailServer.Text, int.Parse(txtPort.Text), chkSSL.Checked);
pop3Client.Authenticate(txtUserName.Text, txtPassword.Text);
Session["Pop3Client"] = pop3Client;
}
else
{
pop3Client = (Pop3Client)Session["Pop3Client"];
}
int count = pop3Client.GetMessageCount();
DataTable dtMessages = new DataTable();
dtMessages.Columns.Add("MessageNumber");
dtMessages.Columns.Add("From");
dtMessages.Columns.Add("Subject");
dtMessages.Columns.Add("DateSent");
int counter = 0;
for (int i = count; i >=1 ; i--)
{
Message message = pop3Client.GetMessage(count);
Message msg = pop3Client.GetMessage(count);
dtMessages.Rows.Add();
dtMessages.Rows[dtMessages.Rows.Count - 1]["MessageNumber"] = count;
dtMessages.Rows[dtMessages.Rows.Count - 1]["Subject"] = message.Headers.Subject;
dtMessages.Rows[dtMessages.Rows.Count - 1]["DateSent"] = message.Headers.DateSent;
counter++;
if (counter > 5)
{
break;
}
}
gvEmails.DataSource = dtMessages;
gvEmails.DataBind();
有人能告诉我如何使用asp.net Web应用程序获取未读的电子邮件信息吗?我只知道如何获取所有电子邮件。我想听这个应用程序的新电子邮件,请帮助我吗?
我还需要下载附件????任何人都告诉我该怎么做..