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);

    }

}


 

How To Add Tool Tip for DropDownList items in Asp.Net


1<asp:DropDownList ID="DropDownList1" runat="server" ondatabound="DropDownList1_DataBound">
2</asp:DropDownList>



Code for .CS File


protected void DropDownList1_DataBound(object sender, EventArgs e)
02{
03    DropDownList ddl = sender as DropDownList;
04    if (ddl != null)
05    {
06        foreach (ListItem li in ddl.Items)
07        {
08           li.Attributes["title"] = li.Text; // setting text value of item as tooltip
09        }
10    }
11 
12}