Click here to Skip to main content
Click here to Skip to main content

Consuming Feeds (Gmail Inbox Sample)

By , 25 Oct 2010
Rate this:
Please Sign up or sign in to vote.

I was in need of retrieving the unread messages from our email (we are using Google Apps). So I started to search how to do this. I found that Google offers an inbox feed. That was great! The problem was that I had never consumed a feed before.

I searched for documentation on how to do this and I found a sample code that consumes the Gmail feed. It was written in C#. We have our web app developed with VB.NET, so I had to translate the code. It was not working for me (probably I wasn't translating it well), so I just modified the sample code (though most of it is just the translation).

I'm going to post the whole thing, I mean, not only the part when we consume the atom feed, but how to convert and display the information we got. In this case, I'm using a DataList control. Let's take a look at the code.

First, our HTML with the DataList where we'll show our Unread Messages (It has just three columns to show the following fields: From, Subject, and Date):

Second, the call to the class that will read the Atom Feed, and how we convert what this class returns to fill our DataList. (I just commented the fields that I don't want to show, if you want to use them, go ahead!)

The code is simple, we instantiate the class GmailAtomFeed passing the email address and its password to the constructor. We call the GetGmailAtom function which returns an XML, and we pass it to a Dataset with one Datatable which will be bound to the DataList...

Click to enlarge

Third, the class itself that reads the Atom Feed:

And that's it. Please feel free to leave any comments, suggestions or questions. As I said, this is based on the sample code that I linked before in this post but with a small modification in the GmailAtomFeed class and a different output.

Hope it helps!


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Software Developer (Senior)
Spain Spain
No Biography provided
Follow on   Twitter

Comments and Discussions

QuestionWhy we access full unread message bobd Pinmembermanish102878-Mar-13 22:41 
We use this code but we have not access full message
but only access sum message budy
why we access full message body
please tell me

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140415.2 | Last Updated 25 Oct 2010
Article Copyright 2010 by nereo.lopez
Everything else Copyright © CodeProject, 1999-2014
Terms of Use
Layout: fixed | fluid