I am using ImapClient by MailKit and trying to move a message from folder A to folder B after reading the message, but the message is not moved and still exists in folder A. What is the problem?
Here is my code:
using (var client = new ImapClient())
{
client.Connect(_config.SmtpServer, _config.Port, true);
client.Authenticate(_config.UserName, _config.Password);
client.Inbox.Open(MailKit.FolderAccess.ReadWrite);
var inbox = client;
var archive = inbox.GetFolder(SpecialFolder.Archive);
archive.Open(FolderAccess.ReadWrite);
var A = inbox.GetFolder("A");
A.Open(FolderAccess.ReadWrite);
for (int i = 0; i < A.Count; i++)
{
if (!A.IsOpen)
A.Open(FolderAccess.ReadWrite);
MimeMessage message = A.GetMessage(i);
//reading email
//....
A.MoveTo(i, archive); //this line doesn't affect the message
}
client.Disconnect(true);
}
The function A.MoveTo(i, archive) doesn’t move the email.
Thank you if you can help me in this case.