views:

241

answers:

3

hi

can anyone tell me how i can get the number o unread items in my inbox from gmail using imap or something else and display it in a label in c# win forms.

i tried using atom feeds but never could get it

here is a pic of what i want to do if it helps

![Inbox(1)][1]

+1  A: 

You probably want to find all messages with the UNSEEN flag set.

Imap imap = new Imap();
/* connect, login, etc. */
imap.Connect(...);
/* fill login and select folder code */

List<long> unseenList = imap.SearchFlag(Flag.Unseen);

// now you can get the count from unseeList
int unread = unseenList.Count;
quantumSoup
Could you elaoborate a bit more im completly new to progrsmming
Shane121
@user See edited answer
quantumSoup
Thanks for the help worked great so how would i show dis in a label
Shane121
A: 

SOLVED

here is the code i used with the ImapX component Get it Free Here

 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

Shane121
A: 

using php what will be the script??

pusp