Import Gmail Contacts Using ASP.Net.

Hi Friends,

Today My Post Is Using Dot Net Application We Can Get The Gamil Contacts.

Steps:

1.Use Need To Get  ” Google.GData.Client.dll” from google.

2.Add Reference In Your Web Application

3.Then Create on Folder Name as App_Name inside that folder create a one class.

4.Inside That Class Right This Code

using Google.GData.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.Contacts;

public class Class1
{
public static DataSet GetGmailContacts(string App_Name,string Uname, string UPassword)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
DataColumn C2 = new DataColumn();
C2.DataType = Type.GetType(“System.String”);
C2.ColumnName = “EmailID”;
dt.Columns.Add(C2);
RequestSettings rs = new RequestSettings(App_Name,Uname, UPassword);
rs.AutoPaging = true;
ContactsRequest cr = new ContactsRequest(rs);
Feed<Contact> f = cr.GetContacts();
foreach (Contact t in f.Entries)
{
foreach (EMail email in t.Emails)
{
DataRow dr1 = dt.NewRow();
dr1["EmailID"] = email.Address.ToString();
dt.Rows.Add(dr1);
}
}
ds.Tables.Add(dt);
return ds;
}
}

5.Now Create Default1.aspx page

create two text box and one button

inside the button click event write this code

//Import This Namespace

using Google.GData.Contacts;
using Google.GData.Client;
using Google.GData.Extensions;
using Google.Contacts;

click_event()

{

Session["username"] = txtUserName.Text;
Session["password"] = txtPassword.Text;
Session["App_Name"] = “MyNetwork Web Application!”;
Response.Redirect(“~/Default2.aspx”);

}

If Your Username ands Password will match This Will redirect to Default2.aspx page,So Create Default2.aspx page in that page load event write this code

6.load_event()

{

string App_Name = Session["App_Name"].ToString();
string username = Session["username"].ToString();
string password = Session["password"].ToString();
//DataSet ds = GContactsImport.GetGmailContacts( username, password);
DataSet ds = Class1.GetGmailContacts(App_Name,username, password);
GridView1.DataSource = ds;
GridView1.DataBind();

}

About these ads

About developersite
I am Dot Net Programmer

One Response to Import Gmail Contacts Using ASP.Net.

  1. Rajesh says:

    thnks a lot ……………..

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: