using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Google.GData.Contacts; using Google.GData.Extensions; using Google.GData.Client; using Google.Contacts; using System.Data.SqlClient; using System.Data; namespace GetDetailsOfGmail { public partial class WebForm1 : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.Tables.Add("GmailContacts"); ds.Tables[0].Columns.Add("EmailId"); RequestSettings rs = new RequestSettings("myApp", txtUserName.Text, txtPassword.Text); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed f = cr.GetContacts(); foreach (Contact contact in f.Entries) { foreach (EMail email in contact.Emails) { DataRow row = ds.Tables[0].NewRow(); row["EmailId"] = email.Address.ToString(); ds.Tables[0].Rows.Add(row); } } GridView1.DataSource = ds.Tables[0]; GridView1.DataBind(); lblStatus.Text = "Total Contacts For" + txtUserName.Text + " : " + ds.Tables[0].Rows.Count.ToString(); } } }