Pages

Subscribe:

Ads 468x60px

Monday, June 20, 2011

Import Gmail Contact and Email Address in asp.net c#

1)  add these dll in you application:- 
Right click on Solution Explorer and add reference option.
using Google.Contacts;
    using Google.GData.Client;
    using Google.GData.Contacts;
    using Google.GData.Extensions;
2) Drag a button which name is "ImportContact" and a TextBox for enter the email id and drag another TextBox for enter the password.  and a listBox for show the contact and email address.
3)  Write this code to Button_Click:--
//Provide Login Information 
RequestSettings rsLoginInfo = new RequestSettings("", txtEmail.Text, txtPassword.Text);
        rsLoginInfo.AutoPaging = true;
// Fetch contacts and dislay them in ListBox
view sourceprint?

ContactsRequest cRequest = new ContactsRequest(rsLoginInfo);

Feed feedContacts = cRequest.GetContacts();

foreach (Contact gmailAddresses in feedContacts.Entries)

{

    Console.WriteLine("\t" + gmailAddresses.Title);

    lstContacts.Items.Add(gmailAddresses.Title);

    foreach (EMail emailId in gmailAddresses.Emails)

    {

        Console.WriteLine("\t" + emailId.Address);

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

    }

}


 

No comments:

Post a Comment