我想导入gmail联系人,但当我试图从联系人获取数据时,它抛出了一个错误
本文关键字:联系人 错误 一个 获取 gmail 导入 数据 | 更新日期: 2023-09-27 18:05:20
我想导入gmail联系人,为此我试图运行以下代码
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;
}
protected void Button1_Click(object sender, EventArgs e)
{
DataSet ds = GetGmailContacts("MyNetwork Web Application!", txtgmailusername.Text, txtpassword.Text);
gvmails.DataSource = ds;
gvmails.DataBind();
}
但是它抛出了一个异常:
请求执行返回意外结果:http://www.google.com/m8/feeds/contacts/default/fullMovedPermanently
当我试图使用
foreach (Contact t in f.Entries)
Install-Package Google.GData.Contacts from your nuget pm你的问题将会解决