需要帮助IMAP INBOX根据收到的日期进行搜索

Bha*_*kar 3 imap

我正在使用开源IMAP C#库IMapX(http://hellowebapps.com/products/imapx/).当我试图从INBOX收到电子邮件时,需要花费很多时间.有没有办法根据收到的日期过滤收件箱?

以下代码是一个示例.搜索基于UNSEEN.我想根据收到的日期过滤大于给定日期.

ImapX.ImapClient client = new ImapX.ImapClient("imap.gmail.com", 993, true);
    bool result = false;

    result = client.Connection();
    if (result)
        MessageBox.Show("Connection Established");

    result = client.LogIn(textBox1.Text, textBox2.Text);
    if (result)
    {
        MessageBox.Show("Logged in");
        ImapX.FolderCollection folders = client.Folders;
        ImapX.MessageCollection messages = client.Folders["INBOX"].Search("UNSEEN", true); //true - means all message parts will be received from server

        int unread = messages.Count;
        string unseen = unread.ToString();
        button1.Text = unseen;
    }
Run Code Online (Sandbox Code Playgroud)

小智 8

您可以使用IMAP搜索数据项SINCE.示例:"SINCE 18-Nov-2011".或者,如果您对UNSEEN感兴趣,那么:"自2011年11月18日至今UNSEEN"

  • 这是我通过这个答案得出的工作代码:`imap_search($ this-> mbox,SINCE"Wed,3 Feb 2010 0:00:00"BEFORE"Sat,2010年2月13日0:00:00")`php's`strtotime ()`和`date('D,j MYG:i:s')`非常有用.仅供参考,上面搜索gmail框和消息检索大约需要20秒. (2认同)