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?
You are using the index here:
for (int i = 0; i < inbox.Count; i++) //
{
var message = inbox.GetMessage(i);
...
}
i
is the index.
In more recent versions of MailKit, I added the ability to do:
inbox.AddFlags (i, MessageFlags.Deleted);
So now you don't need to do this:
inbox.AddFlags (new int[] { i }, MessageFlags.Deleted);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.