在电子邮件上设置删除标志,IMAP收件箱中没有任何反应

时间:2011-09-14 20:18:17

标签: c# exchange-server imap webmail

我通过IMAP连接到网络邮件(Exchange 2003)。

我正在使用mailbee中的库来执行此操作。

我读了一封邮件后,我想删除它。我的问题是它从未从我的邮箱中删除。

所以我的问题是,在Exchange中是否有一些设置允许“外部”用户删除邮件?

    foreach (MailMessage msg in msgs)
    {
        if (msg.HasAttachments)
        {

            foreach (Attachment attach in msg.Attachments)
            {
                // Save the attachment to the file.
                if (Path.GetExtension(attach.Filename).CompareTo(".csv") == 0)
                {
                    path = localFolder + "\\" + attach.Filename;
                    Console.WriteLine("Saved file: " + path);
                    attach.Save(@path, true);

                    paths.Add(path);

                    //deletes the message
                    imp.DeleteMessages(msg.IndexOnServer.ToString(), false);
                    Console.WriteLine("file nr:" + msg.IndexOnServer);
                }
                else
                {
                    Console.WriteLine("Found a different file: " + attach.Filename);
                }
            }

        }
    }

    DbHandler.Add(paths, backupMonths * -1);                

    return true;
}
catch (Exception e)
{
    Console.Out.WriteLine(e);
    return false;
}

这是来自MailBee库的连接的日志

[22:02:18.41] [RECV] Received: from BL2PRD0103MB072.prod.exchangelabs.com ([169.254.7 ... 004_7708CE53FE258F4B9804719502D521C4076B23BL2PRD0103MB072pr_--\r\n [Literal of length 173705.]
[22:02:18.41] [RECV]  FLAGS (\Seen \Deleted))\r\n [Total 173784 bytes received.]
[22:02:18.80] [RECV] * 7 FETCH (UID 8 RFC822.SIZE 126633 BODY[] {173862}\r\n
[22:02:18.80] [RECV] Received: from BL2PRD0103MB072.prod.exchangelabs.com ([169.254.7 ... 004_7708CE53FE258F4B9804719502D521C4076B11BL2PRD0103MB072pr_--\r\n [Literal of length 173862.]
[22:02:18.81] [RECV]  FLAGS (\Seen \Deleted))\r\n [Total 173941 bytes received.]
[22:02:18.81] [RECV] MBN00000004 OK FETCH completed.\r\n [Total 33 bytes received.]
[22:02:18.81] [INFO] Envelopes downloaded
[22:02:18.92] [INFO] Setting flags for messages.
[22:02:18.92] [SEND] MBN00000005 STORE 5 +FLAGS.SILENT (\Deleted)\r\n
[22:02:19.07] [RECV] MBN00000005 OK STORE completed.\r\n [Total 33 bytes received.]
[22:02:19.09] [INFO] Setting flags for messages.
[22:02:19.09] [SEND] MBN00000006 STORE 6 +FLAGS.SILENT (\Deleted)\r\n
[22:02:19.24] [RECV] MBN00000006 OK STORE completed.\r\n [Total 33 bytes received.]
[22:02:19.25] [INFO] Setting flags for messages.
[22:02:19.25] [SEND] MBN00000007 STORE 7 +FLAGS.SILENT (\Deleted)\r\n
[22:02:19.40] [RECV] MBN00000007 OK STORE completed.\r\n [Total 33 bytes received.]
[22:02:35.67] [SEND] MBN00000008 LOGOUT\r\n
[22:02:35.82] [RECV] * BYE Microsoft Exchange Server 2010 IMAP4 server signing off.\r\n [Total 64 bytes received.]
[22:02:35.82] [RECV] MBN00000008 OK LOGOUT completed.\r\n [Total 34 bytes received.]

我认为这应该设置和删除消息。任何人都有任何错误的输入吗?

1 个答案:

答案 0 :(得分:3)

根据the documentation with sample code of Mailbee regarding DeleteMessages,您需要在致电imp.Close()之前致电imp. Disconnect() - 否则邮件将不会被清除。