0 votes
by (200 points)
edited

how can I implement in your project search messages by Imap and output them in any number of variable?

Applies to: Rebex Secure Mail
by (58.9k points)
edited

I am sorry I do not understand your requirements - could you please be more specific? You might also want to have a look at our IMAP tutorials as well as our IMAP samples which are part of the Rebex Secure Mail package - namely IMAP GUI Browser, IMAP Console Client and IMAP Downloader.

by (200 points)
edited

I want to search for posts by Imap but do not know how to display the count

4 Answers

0 votes
by (58.9k points)
edited

You can display the messages count on the IMAP server Inbox folder with this code snippet:

Imap client = new Imap();
client.Connect("test.rebex.net");
client.Login("demo", "password");

client.SelectFolder("Inbox");
//count of total and unread messages is accessible directly through a property:
Console.WriteLine("Total messages count: {0}", client.CurrentFolder.TotalMessageCount);
Console.WriteLine("Unread messages count: {0}", client.CurrentFolder.NotSeenMessageCount);
client.Disconnect();
0 votes
by (200 points)
edited

example I want to find a letter from rebex via Imap. I then display the number of letters found?

by (58.9k points)
edited

The following code snippet finds messages which were sent by support@rebex.net and then shows their count:

Imap client = new Imap();
client.Connect("imap.gmail.com", SslMode.Implicit);
client.Login("user@gmail.com", "password");

client.SelectFolder("Inbox");

// find messages from "support@rebex.net"
ImapMessageCollection fromRebex = client.Search
(
    ImapSearchParameter.From("support@rebex.net")
);

Console.WriteLine("There are {0} messages from 'support@rebex.net'", fromRebex.Count);

client.Disconnect();
by (200 points)
edited

Thank you very much!

0 votes
by (200 points)
edited
try
        {
            Imap clientt = new Imap();
            clientt.Connect("imap.yandex.ru");
            clientt.Login("elseeker@yandex.ru", "******");
            clientt.SelectFolder("Inbox");


            // find messages from "support@rebex.net"
            ImapMessageCollection fromRebex = clientt.Search
            (
                ImapSearchParameter.From("embarcadero.com")
            );
            MessageBox.Show("2");
            MessageBox.Show("messages " + fromRebex.Count);
            //  Console.WriteLine("There are {0} messages from 'support@rebex.net'", fromRebex.Count);

          //  clientt.Disconnect();
        }
        catch { MessageBox.Show("error"); }

error!

0 votes
by (58.9k points)
edited

Please modify your code to log into the logwriter like this and send us the created log as well as content of the ex.ToString():

    try
    {
        Imap clientt = new Imap();
        clientt.LogWriter = new Rebex.FileLogWriter(@"c:\temp\log.txt", Rebex.LogLevel.Debug);

        clientt.Connect("imap.yandex.ru");
        clientt.Login("elseeker@yandex.ru", "******");
        clientt.SelectFolder("Inbox");

        ImapMessageCollection fromRebex = clientt.Search
        (
            ImapSearchParameter.From("embarcadero.com")
        );
        MessageBox.Show("2");
        MessageBox.Show("messages " + fromRebex.Count);
    }
    catch (Exception ex){ MessageBox.Show(ex.ToString()); }

Seeing the log would enable us to see what is going on and help you solve this issue.

...