Click here to Skip to main content
15,892,575 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello All

Please tell me How to retrive unread emails using POP3.

I am using SSL 995 port pop.gmail.com and correct username and password

but gives error as "server did not accept user credentials"

I am using OpenPop.dll from sourge fprce

http://sourceforge.net/projects/hpop/?source=directory[^]

Posted
Comments
[no name] 4-Mar-13 9:16am    
Well then it would appear that you did not supply the correct credentials. Hard to tell you what you did wrong when you did not post any code that demonstrates any kind of a problem....

1 solution

how to retrieve just unread emails using pop3
C#
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;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900