andyedinborough / aenetmail

C# POP/IMAP Mail Client
369 stars 153 forks source link

System.Exception while moving mail on Gmail #194

Open Atrejoe opened 7 years ago

Atrejoe commented 7 years ago

Using 1.7.10.0 (See also #193):

When moving a mail from one folder to another in Gmail (which will present this as tags), I always seems to get an error on the first try.

using (var client = GetMailClient())
{
    client.SelectMailbox(currentfolder);

    try
    {
        client.MoveMessage(messageId, targetFolder);
    }
    catch (Exception)
    {
        //Quite often (almost always) when moving a message a generic system.exception is thrown (during the delete part)
        //, which seems to be a misunderstanding between either AE.Net.Mail or the Gmail IMAP interface
        client.MoveMessage(messageId, targetFolder); //The second pass always seems to succeed.
    }
}

System.Exception.Message: 1 FETCH (UID 23 FLAGS (\\Flagged)) (or some variation)

Stack trace:

   at AE.Net.Mail.ImapClient.CheckResultOK(String response) in c:\Repos\aenetmail\ImapClient.cs:line 821
   at AE.Net.Mail.TextClient.SendCommandCheckOK(String command) in c:\Repos\aenetmail\TextClient.cs:line 121
   at AE.Net.Mail.ImapClient.Copy(String messageset, String destination) in c:\Repos\aenetmail\ImapClient.cs:line 257
   at AE.Net.Mail.ImapClient.MoveMessage(String uid, String folderName) in c:\Repos\aenetmail\ImapClient.cs:line 339

The message IS actually copied to the correct folder, but as an exception is thrown, it is not deleted from the original folder.

Upon the second attempt all goes well, hence the blind retry.