Need Help on IMAP INBOX Search based on received d

2019-05-11 17:01发布

问题:

I am using a Open source IMAP C# library IMapX (http://hellowebapps.com/products/imapx/). When I trying to get the emails from INBOX it is taking lot of time. Is there any way to Filter inbox based on received date?

The below code is a sample. The search is based on UNSEEN. I want to filter based on received date is Greater than given date.

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

回答1:

You can use IMAP search data item SINCE. Example: "SINCE 18-Nov-2011". Or if you interested in UNSEEN too then: "SINCE 18-Nov-2011 UNSEEN"



标签: imap