Pravat Bera

Pravat Bera

  • NA
  • 9
  • 805

how to retrieve contacts from gmail in asp.net

Oct 13 2017 8:35 AM
i am using code blow but there is an error : - Additional information: Execution of authentication request returned unexpected result: 404
 
Here Is The Code 
 
public DataSet GetGmailContacts(string App_Name, string Uname, string UPassword)
{
DataSet ds = new DataSet();
DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("EmailID", typeof(string)));
dt.Columns.Add(new DataColumn("Name", typeof(string)));
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 dr = dt.NewRow();
dr["EmailID"] = email.Address.ToString();
dr["Name"] = t.Title.ToString();
dt.Rows.Add(dr);
}
}
ds.Tables.Add(dt);
return ds;
}
protected void Page_Load(object sender, EventArgs e)
{
}
protected void btnLogin_Click(object sender, EventArgs e)
{
DataSet ds = GetGmailContacts("Gmail Contact Operations", txtName.Text, txtPwd.Text);
ViewState["Contact"] = ds;
gvContacts.DataSource = ds;
gvContacts.DataBind();
}
protected void gvContacts_PageIndexChanging(object sender, GridViewPageEventArgs e)
{
DataSet ds = ViewState["Contact"] as DataSet;
gvContacts.PageIndex = e.NewPageIndex;
gvContacts.DataSource = ds;
gvContacts.DataBind();
}
 

Answers (1)