views:

265

answers:

1

Hi, I have used an open source code from codeproject to read email from incoming mail server(POP Server). The code can be found at following location: http://www.codeproject.com/KB/IP/Pop3MimeClient.aspx

So far it works fine i can read emails.

My objective of using this code was to retrieve emails from POP server and process them.

My problem is: If i use gmails pop server "pop.gmail.com" and run the appplication. I get only those emails that i have not retrieved since the last time i run the application. but if i use my clients pop server everytime i run the application i get all the emails in the pop server.

for example: If i use gmail pop server: pop.gmail.com I have three emails in the pop server. I haven't run the application. I am running the application for the first time. Application reads the email, this time i will get 3 all the three email. I run the application second time, my application will not read any emails this time because i have already read the 3 existing one. This is fine, this is what i want. Now i send email to pop.gmail.com. I run the application again for the third time, this time i will only get the email that has just arrived that is the fourth one. This is good behaviour, this is what i want.

But if i use my clients pop server: No matter how many times i run the application, it reads all the emails in the mail box.

This will create problem for me, because i am thinking of building a window service that will read emails from pop server and process them. This service will run continuously. I will process emails in the pop serve then sleep for let's say 1 minute and the process the emails again. If the application downloaded from codeproject reads all the emails all the time, my clients mailbox can have like thousands for email in this mail box, so this would not be feasible for me.

Is there some settings that is to be made at my client's pop server that will allow my application to retrieve only those emails that i have not read since last time i run the service or any help

Please help, thanks,

+3  A: 

Do not use Gmail's implementation of POP or IMAP as canonical; both of these protocols behave differently with Gmail accounts than with virtually any other server.

To answer your question, you have two approaches that you can take:

  1. Keep track of the message ID's of the messages that you've seen and ignore them on subsequent connections (this will leave the messages on the server for another client to download).
  2. Issue the DELE command after downloading a message, which will remove it from the server.
Adam Robinson
+1 very good answer.
adatapost