Can't mark e-mail read with InterIMAP, folder is read-only

I am trying to mark emails read (/ SEEN) with InterIMAP, but it doesn't work. I went through the code with the debugger and found out that the response from the mail server "IMAP0078 OK Store is being ignored by the read-only mailbox", which pretty much tells me why it doesn't work. But there seems to be no way to tell InterIMAP to open the connection as read-write. If I am using something like Thunderbird, I can configure the messages to be read.

Does anyone know how I should use InterIMAP to achieve what I am trying, or how to modify the source code so that I can mark messages as read?

+1


source to share


2 answers


I managed to fix the situation with the following change: Imap.cs

public void MarkMessageAsRead(IMAPMessage msg)
{
    string cmd = "UID STORE {0} +FLAGS (\\Seen)\r\n";
    ArrayList result = new ArrayList();
    SendAndReceive(String.Format(cmd, msg.Uid), ref result);
    if (result[0].ToString().ToLower().Contains("ok"))
        msg.Flags.New = false;
}

      

Changed to



 public void MarkMessageAsRead(IMAPMessage msg)
    {
        msg.Folder.Select();
        string cmd = "UID STORE {0} +FLAGS (\\Seen)\r\n";
        ArrayList result = new ArrayList();
        SendAndReceive(String.Format(cmd, msg.Uid), ref result);
        if (result[0].ToString().ToLower().Contains("ok"))
            msg.Flags.New = false;
        msg.Folder.Examine();
    }

      

Not sure if this is the cleanest way to fix my problem, but it's better than nothing.

0


source


Share with your friends and acquaintances with us!



    public void DeleteMail(IMAPMessage msg)
    {
        msg.Folder.Select();
        string cmd = "UID STORE {0} +FLAGS (\\Deleted \\Seen)\r\n";
        ArrayList result = new ArrayList();
        SendAndReceive(String.Format(cmd, msg.Uid), ref result);

        int countResult = result.Count - 1;

        while (countResult >= 0)
        {
            if (result[countResult].ToString().ToLower().Contains("ok"))
            {
                msg.Flags.New = false;
                msg.Flags.Deleted = true;

                string cmd2 = "EXPUNGE\r\n";
                ArrayList result2 = new ArrayList();
                SendAndReceive(String.Format(cmd2, msg.Uid), ref result2);

                if (result2[0].ToString().ToLower().Contains("ok"))
                {
                    //Deu certo!!
                    msg.Folder.Examine();
                }

            }

            countResult--;
        }
    }

      

0


source







All Articles