如何使用POP3检索未读电子邮件
问题描述:
大家好您好
请告诉我如何使用POP3回复未读电子邮件。
我正在使用SSL 995 port pop.gmail.com和正确的用户名和密码
但是因服务器不接受用户凭据而给出错误
我正在使用来自sourge fprce的OpenPop.dll
http://sourceforge.net/projects/hpop/?source=directory [ ^ ]
答
如何使用pop3检索未读的电子邮件
how to retrieve just unread emails using pop3
public void Main()
{
int start = int.parse(Request.QueryString("start"));
int count = int.parse(Request.QueryString("count"));
List<string> subjects = new List<string>();
subjects = getSubjects(start, count);
//Do whatever with the results...
//
}
public List<string> getSubjects(int startItem, int endItem)
{
Pop3Client popp = new Pop3Client("user@mail.com", "*******", "pop3.mail.com");
popp.AuthenticateMode = Pop3AuthenticateMode.Pop;
popp.Port = 110;
popp.Authenticate();
List<string> msglist = new List<string>();
if (popp.State == Pop3ConnectionState.Authenticated) {
int totalmsgs = popp.GetTotalMessageCount();
int endItem = countItems + startItem;
if (endItem > totalmsgs) {
endItem = totalmsgs;
}
if (totalmsgs > 0) {
for (int index = startItem; index <= endItem; index++) {
Pop3Message msg = popp.GetMessage(index);
msglist.Add(msg.Subject);
}
popp.Close();
}
}
return msglist;
}