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