1

I've found this:

client.Inbox.AddFlags (new int[] { index }, MessageFlags.Deleted);
or
client.Inbox.AddFlags (new UniqueId[] { uid }, MessageFlags.Deleted);

then
client.Inbox.Expunge ();

I don't know how to obtain index or uid to use here. My client works like this:

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 < inbox.Count; i++) // 
                {
                    var message = inbox.GetMessage(i);
                    ...
                }
}

Also int I is not the index. message.MessageID not equal to UID. Where is my mistake?

4

1 回答 1

6

您在这里使用索引:

for (int i = 0; i < inbox.Count; i++) // 
{
    var message = inbox.GetMessage(i);
    ...
}

i是索引。

在更新的 MailKit 版本中,我添加了以下功能:

inbox.AddFlags (i, MessageFlags.Deleted);

所以现在你不需要这样做:

inbox.AddFlags (new int[] { i }, MessageFlags.Deleted);
于 2014-07-14T10:30:19.767 回答