无法使用 InterIMAP 标记电子邮件已读,文件夹为只读

发布于 2024-08-26 06:13:13 字数 248 浏览 7 评论 0原文

我尝试使用 InterIMAP 将电子邮件标记为已读 (/SEEN),但这不起作用。我用调试器单步调试代码,发现邮件服务器的响应是“IMAP0078 OK Store被只读邮箱忽略。”,这几乎告诉我为什么它不起作用。但看起来没有办法告诉 InterIMAP 以读写方式打开连接。如果我使用 Thunderbird 之类的东西,我可以将消息设置为已读。

有谁知道我应该如何使用 InterIMAP 来实现我正在尝试的目标,或者如何更改源代码以便我能够将消息标记为已读?

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

Does anyone know how I should use InterIMAP to achieve what I'm trying, or how to change the source code so that I'd be able to mark messages as read?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不及他 2024-09-02 06:13:13

我能够通过对 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;
}

更改为

 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();
    }

不确定这是否是解决我的问题的最干净的方法,但总比没有好。

I was able to fix the situation with the following change to 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.

烟燃烟灭 2024-09-02 06:13:13

继续调整 IMAP GMAIL 删除程序的功能!

    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--;
        }
    }

Segue código ajustado que funcionou para remover a mensagem da caixa IMAP GMAIL!

    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--;
        }
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文