Get unread mails in gmail inbox using C#

1,423 views
Skip to first unread message

Lauren

unread,
Nov 9, 2009, 8:59:48 AM11/9/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Hi,

I need to get the number of unread mails from my gmail inbox and loop
through these messages and extract the body.

I have managed to get most of the code working, however I am
struggling with getting the number of messages.
I can connect, but can only get one message at a time, whereas I need
it to loop through all the unread messages.


I'm using C#.

Any help would be appreciated.

Lauren

Jamie Fraser

unread,
Nov 9, 2009, 10:08:46 AM11/9/09
to dotnetde...@googlegroups.com
Post a code sample please - we have no idea what libraries you are using and therefore cannot advise.

Mike Fry

unread,
Nov 9, 2009, 10:11:45 AM11/9/09
to dotnetde...@googlegroups.com
Jamie Fraser wrote:
> Post a code sample please - we have no idea what libraries you are using
> and therefore cannot advise.

Also, are you familiar with the POP protocol?

--
Best regards,
Mike Fry
Johannesburg.

Message has been deleted

Mike Fry

unread,
Nov 10, 2009, 3:56:13 AM11/10/09
to dotnetde...@googlegroups.com
Lauren wrote:

> I'm currently at a loss on how to proceed from here. I've tried using
> the LIST command, but it returns message ID's and the size of the
> mails, which is not what I'm looking for. Is there another command I
> can use?

No wonder you're at a loss! POP is plain text not web based. Get yourself a
copy of RFC 1939 from the IETF.

Processor Devil

unread,
Nov 10, 2009, 4:04:55 AM11/10/09
to dotnetde...@googlegroups.com
why the RFC?
On internet is a lot of complete solutions (even in c#), she can look through and see some practical example how it works

2009/11/10 Mike Fry <mik...@iafrica.com>

Mike Fry

unread,
Nov 10, 2009, 4:23:34 AM11/10/09
to dotnetde...@googlegroups.com
Processor Devil wrote:
> why the RFC?
> On internet is a lot of complete solutions (even in c#), she can look
> through and see some practical example how it works

Give hand-outs and the hand will always be out. Teach a man to fish and he'll
feed himself.

Processor Devil

unread,
Nov 10, 2009, 4:25:55 AM11/10/09
to dotnetde...@googlegroups.com
I just wanted to say... she doesn't need to learn the complete POP protocol if she can search specific things she wants using google ;-)

2009/11/10 Mike Fry <mik...@iafrica.com>

Cerebrus

unread,
Nov 10, 2009, 11:45:45 AM11/10/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
The OP is apparently female. That adage does not stand for women !

Correction: "... Teach a woman to fish and she'll feed the whole
neighbourhood."

:P

Benj Nunez

unread,
Nov 10, 2009, 7:39:30 PM11/10/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
I think the correct quote is:

"Give a Man a Fish, Feed Him For a Day. Teach a Man to Fish, Feed Him
For a Lifetime" --Lau Tzu

Source:

http://ezinearticles.com/?Lao-Tzu---Give-A-Man-A-Fish,-Feed-Him-For-A-Day.-Teach-A-Man-To-Fish,-Feed-Him-For-A-Lifetime&id=512280





Cheers!


Benj

Charles A. Lopez

unread,
Nov 10, 2009, 10:50:27 PM11/10/09
to dotnetde...@googlegroups.com
Go to the fish store. Buy the fish.

2009/11/10 Benj Nunez <benj...@gmail.com>

Lauren

unread,
Nov 11, 2009, 2:21:10 AM11/11/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
And strangely, this has not helped at all. By the way Mike, I'm not
looking for someone to write the code for me, I'm just wanting to be
pointed in the right direction.

On Nov 11, 5:50 am, "Charles A. Lopez" <charlesalo...@gmail.com>
wrote:
> Go to the fish store. Buy the fish.
>
> 2009/11/10 Benj Nunez <benjnu...@gmail.com>
>
>
>
>
>
> > I think the correct quote is:
>
> > "Give a Man a Fish, Feed Him For a Day. Teach a Man to Fish, Feed Him
> > For a Lifetime" --Lau Tzu
>
> > Source:
>
> >http://ezinearticles.com/?Lao-Tzu---Give-A-Man-A-Fish,-Feed-Him-For-A...
>
> > Cheers!
>
> > Benj
>
> > On Nov 11, 12:45 am, Cerebrus <zorg...@sify.com> wrote:
> > > The OP is apparently female. That adage does not stand for women !
>
> > > Correction: "... Teach a woman to fish and she'll feed the whole
> > > neighbourhood."
>
> > > :P
>
> > > On Nov 10, 2:23 pm, Mike Fry <mike...@iafrica.com> wrote:
>
> > > > Give hand-outs and the hand will always be out. Teach a man to fish and
> > he'll
> > > > feed himself.- Hide quoted text -
>
> - Show quoted text -

Processor Devil

unread,
Nov 11, 2009, 3:46:14 AM11/11/09
to dotnetde...@googlegroups.com
ok, here is "your strategy":
So you want to read all unread files on gmail using .NET.
OK. If you want to do it, you need to set up your gmail account to provide you pop3 (can be found in account settings)
Next step is you need to learn something about POP3, I would recommend you to go to www.answers.com/POP3
Some good points can be found there. Actually, I have been using Answers.com for ages and it always provided my some usefull stuff :)
Ok, so if you did it correctly now you know that POP3 resides on port 110 and it is simple SMTP-like protocol... Communication runs via socket and you send text request and obtain text response (text parsing skills will be ok for sure).

Now we will try our old friend google.
I used keywords
POP3 commands
and these two links were in the top:
http://www.yuki-onna.co.uk/email/pop.html (reading e-mails using telnet)
http://www.good-stuff.co.uk/useful/pop3.php (some pop3 commands)

and maybe this will be useful to you as well
http://techhelp.santovec.us/pop3telnet.htm (similar like the first link).

So, what you need for programming this:
Knowledge of sockets, parsing text and not too lazy fingers while using Google. HAWK

2009/11/11 Lauren <lauren...@gmail.com>

Mike Fry

unread,
Nov 11, 2009, 4:30:58 AM11/11/09
to dotnetde...@googlegroups.com
Benj Nunez wrote:
> I think the correct quote is:
>
> "Give a Man a Fish, Feed Him For a Day. Teach a Man to Fish, Feed Him
> For a Lifetime" --Lau Tzu
>

I was paraphrasing :-)

Lauren

unread,
Nov 11, 2009, 4:49:22 AM11/11/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Thanks so much for the help. I'll check it out now.

On Nov 11, 10:46 am, Processor Devil <processor.de...@gmail.com>
wrote:
> ok, here is "your strategy":
> So you want to read all unread files on gmail using .NET.
> OK. If you want to do it, you need to set up your gmail account to provide
> you pop3 (can be found in account settings)
> Next step is you need to learn something about POP3, I would recommend you
> to go towww.answers.com/POP3
> Some good points can be found there. Actually, I have been using Answers.com
> for ages and it always provided my some usefull stuff :)
> Ok, so if you did it correctly now you know that POP3 resides on port 110
> and it is simple SMTP-like protocol... Communication runs via socket and you
> send text request and obtain text response (text parsing skills will be ok
> for sure).
>
> Now we will try our old friend google.
> I used keywords
> POP3 commands
> and these two links were in the top:http://www.yuki-onna.co.uk/email/pop.html(reading e-mails using telnet)http://www.good-stuff.co.uk/useful/pop3.php(some pop3 commands)
>
> and maybe this will be useful to you as wellhttp://techhelp.santovec.us/pop3telnet.htm(similar like the first link).
>
> So, what you need for programming this:
> Knowledge of sockets, parsing text and not too lazy fingers while using
> Google. HAWK
>
> 2009/11/11 Lauren <lauren.kru...@gmail.com>
> > > - Show quoted text -- Hide quoted text -

ThanderMaX

unread,
Nov 11, 2009, 1:48:06 PM11/11/09
to DotNetDevelopment, VB.NET, C# .NET, ADO.NET, ASP.NET, XML, XML Web Services,.NET Remoting
Working with GMAIL in POP3 is in total mess ... even good'ld outlook
hangs !

Now google is also recommending IMAP. Atleast it can fetch message
header fast. Skimming message in gmail POP3 will kick u out as it is
bandwidth intensive for google.

On Nov 11, 2:49 pm, Lauren <lauren.kru...@gmail.com> wrote:
> Thanks so much for the help. I'll check it out now.
>
> On Nov 11, 10:46 am, Processor Devil <processor.de...@gmail.com>
> wrote:
>
> > ok, here is "your strategy":
> > So you want to read all unread files on gmail using .NET.
> > OK. If you want to do it, you need to set up your gmail account to provide
> > you pop3 (can be found in account settings)
> > Next step is you need to learn something about POP3, I would recommend you
> > to go towww.answers.com/POP3
> > Some good points can be found there. Actually, I have been using Answers.com
> > for ages and it always provided my some usefull stuff :)
> > Ok, so if you did it correctly now you know that POP3 resides on port 110
> > and it is simple SMTP-like protocol... Communication runs via socket and you
> > send text request and obtain text response (text parsing skills will be ok
> > for sure).
>
> > Now we will try our old friend google.
> > I used keywords
> > POP3 commands
> > and these two links were in the top:http://www.yuki-onna.co.uk/email/pop.html(readinge-mails using telnet)http://www.good-stuff.co.uk/useful/pop3.php(somepop3 commands)
>
> > and maybe this will be useful to you as wellhttp://techhelp.santovec.us/pop3telnet.htm(similarlike the first link).
Reply all
Reply to author
Forward
0 new messages