无法用InterIMAP标记电子邮件,文件夹为只读 [英] Can't mark email read with InterIMAP, folder is read-only
问题描述
我正在尝试使用InterIMAP标记电子邮件(/ SEEN),但这并不奏效。我使用调试器浏览代码,发现邮件服务器的响应是IMAP0078 OK存储器以只读邮箱忽略,这几乎告诉我为什么它不起作用。但是,似乎没有办法告诉InterIMAP将连接打开为读写。如果我使用像Thunderbird这样的东西,我可以将消息设置为read。
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.
有人知道我应该如何使用InterIMAP来实现我正在尝试的内容,或者如何改变源代码,以便我能够将消息标记为已读?
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?
推荐答案
我可以用以下更改为Imap.cs
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;
}
更改为
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.
这篇关于无法用InterIMAP标记电子邮件,文件夹为只读的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!