<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <title></title> </head> <body> <form id="form1" runat="server"> <div> <table> <tr> <td> User Name:<asp:TextBox ID="txtUserName" runat="server"></asp:TextBox> </td> </tr> <tr> <td> Password:<asp:TextBox ID="txtPassword" runat="server"></asp:TextBox> </td> </tr> <tr> <td> <asp:Button ID="btnSubmit" Text="Get Gmail Contacts List" runat="server" onclick="btnSubmit_Click" /> </td> </tr> <tr> <td> <asp:Label ID="lblstatus" runat="server"></asp:Label> </td> <td></td> </tr> <tr> <td colspan="2"> <asp:GridView ID="GridView1" runat="server" Width="100%"> </asp:GridView> </td> </tr> </table> </div> </form> </body> </html>
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using Google.Contacts; using Google.GData.Contacts; using Google.GData.Client; using Google.GData.Extensions; using System.Data; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnSubmit_Click(object sender, EventArgs e) { DataSet ds = new DataSet(); ds.Tables.Add("GmailContacts"); ds.Tables[0].Columns.Add("EmailId"); RequestSettings rs = new RequestSettings("Idea Elan2", txtUserName.Text, txtPassword.Text); rs.AutoPaging = true; ContactsRequest cr = new ContactsRequest(rs); Feed<Contact> 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(); } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)