web analytics

Import Google Contacts – ASP.NET

Reading Time: 1 minute

How can we download our google address book to some local DB, file etc? One of the coolest things google has provided for developers is the Google Data API for integration of user and google applications.

And for importing google contacts, firstly we need to download Google Data API and install them to get the required dlls. Then create a web application in Visual Studio, and add those dlls in your bin folder, or add reference of these dlls in your application.

Following dlls are being used for importing address book:

  • Google.GData.Client
  • Google.GData.Contacts
  • Google.GData.Extensions

Now place the required textboxes and button to fetch address book (Two textboxes for username and password, one listbox for address book and one button to start fetching).

following is the code snippet for declaring dll classes in your code behind:

using Google.Contacts;

using Google.GData.Contacts;

using Google.GData.Client;

using Google.GData.Extensions;

following code snippet is to be written behind your button’s click event:

protected void btnAddressBook_Click(object sender, EventArgs e)

{

//Login Information

RequestSettings requestLoginInfo = new RequestSettings(“”, txtEmail.Text, txtPassword.Text);

rsLoginInfo.AutoPaging = true;

// Fetch addressbook and dislay them in ListBox

ContactsRequest conRequest = new ContactsRequest(requestLoginInfo);

Feed <contact> feedContacts = conRequest.GetContacts();

foreach (Contact addressbook in feedContacts.Entries)

{
// Adding contact

lstContacts.Items.Add(addressbook.Title);

foreach (EMail emailId in addressbook.Emails)

{
// Adding Emails for specific contact

lstContacts.Items.Add(” ” + emailId.Address);

}

}

}

2 thoughts on “Import Google Contacts – ASP.NET

  • April 25, 2012 at 4:23 am
    Permalink

    How to retrieve contacts without password, using opengraph oAuth? like quora.com it does

  • May 31, 2012 at 3:19 am
    Permalink

    It through error while impoting contact of another location id

Leave a Reply

%d bloggers like this: