How to read mail from gmail in

In this post,I will show you how to read mail from gmail in


<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">
<html xmlns="">
<head runat="server">
    <form id="form1" runat="server">
        UserName :
    <asp:TextBox ID="txtUserName" runat="server"></asp:TextBox><br />
    <asp:TextBox ID="txtPassword" runat="server" TextMode="Password"></asp:TextBox><br />
    <asp:Button ID="btnLogin" runat="server" Text="Login" OnClick="btnLogin_Click" /><br />
    <asp:GridView ID="grdMail" runat="server">
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net;
using System.Text;
using System.Xml.Linq;
public partial class Default2 : System.Web.UI.Page
    protected void Page_Load(object sender, EventArgs e)
    protected void btnLogin_Click(object sender, EventArgs e)
        XNamespace ns = "";
    string userName = txtUserName.Text;
    string password = txtPassword.Text;
    string gmailFeedUrl = @" ";
        WebClient client = new WebClient();
    string credential = string.Format("{0}:{1}", userName, password);
    string auth = "Basic" + Convert.ToBase64String(Encoding.ASCII.GetBytes(credential));
        client.Headers.Add("Authorization", auth);
    var inboxXml = client.DownloadString(gmailFeedUrl);
    var xml = XDocument.Parse(inboxXml);
    var query = from entry in xml.Descendants(ns + "entry")
                    select new
                        Title = entry.Element(ns + "title").Value,
                        Author = entry.Element(ns + "author").Element(ns + "name").Value,
        grdMail.DataSource = query;


  1. Is there any way how to include in the the read message? thank you

  2. thanks dude ......its very helpful