title: c# MailKit how to delete an email from mail server (IMAP)
body: <p>I've found this:</p>
  
  <pre><code>client.Inbox.AddFlags (new int[] { index }, MessageFlags.Deleted);
  or
  client.Inbox.AddFlags (new UniqueId[] { uid }, MessageFlags.Deleted);
  
  then
  client.Inbox.Expunge ();
  </code></pre>
  
  <p>I don't know how to obtain index or uid to use here. My client works like this:</p>
  
  <pre><code>using (var client = new ImapClient())
  {
                  client.Connect(serverM.Text, Convert.ToInt32(portM.Text), true);
                  client.AuthenticationMechanisms.Remove("XOAUTH");
                  client.Authenticate(user.Text, pass.Text);
                  var inbox =  client.GetFolder(inbox.Text);
                  inbox.Open(FolderAccess.ReadWrite);
                  var message = inbox.GetMessage(i);
                  for (int i = 0; i &lt; inbox.Count; i++) // 
                  {
                      var message = inbox.GetMessage(i);
                      ...
                  }
  }
  </code></pre>
  
  <p>Also int I is not the index. message.MessageID not equal to UID. Where is my mistake?</p>