title: How can i check for new emails and if there are new emails to get them using MailKit?
body: <p>Now i'm just getting all the messages in a backgroundworker dowork event:</p>
  
  <p>private int numberofallmessages = 0;
          private int countMsg = 0;</p>
  
  <pre><code>    private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
      {
          List&lt;string&gt; uids = new List&lt;string&gt;();
          using (var client = new Pop3Client())
          {
              client.Connect(textServer.Text, Convert.ToInt32(textPort.Text), ssl);
              client.AuthenticationMechanisms.Remove("XOAUTH2");
              client.Authenticate(textUser.Text, textPassword.Text);
  
              for (int i = client.Count -1; i &gt; 0; i--)
              {
                  if (backgroundWorker1.CancellationPending == true)
                  {
                      e.Cancel = true;
                      return;
                  }
                  if (i &gt; 0)
                  {
                      allMessages.Add(client.GetMessage(i));
                  }
                      int nProgress = (client.Count - i + 1) * 100 / client.Count;
                      backgroundWorker1.ReportProgress(nProgress, client.Count.ToString() + "/" + i);
              }
  
              client.Disconnect(true);
          }
     }
  </code></pre>
  
  <p>I'm getting all the messages about 6000.
  Now i want to have in a button click event a code so each time i click on the button it will check for a new email. Same idea like in outlook for example.</p>
  
  <p>And also maybe to use an event that will automatic give a notice when a new emails arraived.</p>
  
  <p>I saw this code example:</p>
  
  <p><a href="http://www.mimekit.net/docs/html/E_MailKit_MailFolder_CountChanged.htm" rel="nofollow">MailKit E_MailKit_MailFolder_CountChanged</a></p>
  
  <p>But first i'm not sure if this is what i need/want in my case and second in the example they are using imap but in my code i'm using pop3 and also my account i'm using in the backgroundworker in the Authenticate is a pop3 account.</p>
  
  <p>I want that once after i got all messages like 6000 from now on when clicking the button it will check/get only new emails and not all over again the 6000 emails.</p>