0

I was trying to get new emails using OpenPop.Net. I see this example and noticed this example assumes that when we are connected to pop client, email indexes(ids) will not change (when uses index to fetch new email).

    for(int i = 0; i<uids.Count; i++)
    {
       //...
       //then
       Message unseenMessage = client.GetMessage(i + 1);
       //...
    }

However it is possible that we receive new email(s).

Is this assumption true even if we receive new email(s)?

EDIT: I do not speak about UID. I mean, we use the for loop to get the i-th new email with client.GetMessage(i), but if we receive a new email when we are in loop and it change index (this new email can be geted by client.GetMessage(1)). doesn't it mean we lost an email or for connected client this new one will ignore?

Hello
  • 3
  • 3

2 Answers2

0

Yes, the existing message UIDs are not changed when new mail is received. Otherwise that technique wouldn't work.

I don't see how this relates to your question title. It shouldn't ignore new emails. However you might have to rescan the emails from the beginning to find the new emails.

Robin Green
  • 32,079
  • 16
  • 104
  • 187
  • thank for reply, but I do not speak about UID. I say we use the `for` loop to get the i-th new email with `client.GetMessage(i)`, but if we receive a new email when we are in loop and it change index (this new email can be geted by `client.GetMessage(1)`) doesn't it mean we lost an email? – Hello May 20 '18 at 07:03
  • It's maybe possible, but then on the next rescan you would find it. The important thing is to rescan from the start every minute or two. – Robin Green May 20 '18 at 07:06
  • thanks. I was code a method to start from newest email and go back and search for last read email (so do not search through all emails). it seems it will not work. – Hello May 20 '18 at 07:14
0

The way the POP3 protocol works is that new messages are ignored until you log out and log back in again.

In other words, when you authenticate to the server, what your client sees is a snapshot of that moment in time when you first logged in. In order to see new messages, you will need to reconnect.

jstedfast
  • 35,744
  • 5
  • 97
  • 110
  • thank for reply. I tested it by creating a form with three button connect/disconnect/get and used gmail. it worked as you mentioned. – Hello May 22 '18 at 06:31