Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

Can anyone tell me how I can get the number of unread items in my inbox from gmail using imap or something else and display it in a label in C# WinForms?

I tried using atom feeds, but never could get it

Here is what I want to look like, if it helps:

Inbox(1)

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
326 views
Welcome To Ask or Share your Answers For Others

1 Answer

SOLVED

Here is the code i used with the ImapX component:

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

i just had to covert the int to a string and show the string (unseen) in the button. Thanks to quantumSoup for pointing me in the right direction


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...