如何更新Gmail联系人?

时间:2015-11-25 12:56:55

标签: c# gdata google-contacts

我正在使用GData执行联系人和群组操作。我可以添加联系人,但我无法更新联系人。

Uri feedUri = new Uri(string.Format("{0}/{1}", ContactsQuery.CreateContactsUri("default"), localContact.GmailContactId.Split('/').Last()));
//Get existing contact from Google
Google.Contacts.Contact contact = contactRequest.Retrieve<Google.Contacts.Contact>(feedUri);

contact.Name = new Name()
{
    FullName = string.Format("{0} {1} {2}", localContact.FirstName, localContact.MiddleName, localContact.Lastname),
    GivenName = localContact.FirstName,
    FamilyName = localContact.Lastname,
};

contact.Emails.Add(new EMail()
{
    Rel = ContactsRelationships.IsWork,
    Address = localContact.Email
});

contact.Title = localContact.DisplayName;

// Set the contact's postal address.
contact.PostalAddresses.Add(new StructuredPostalAddress()
{
    Rel = ContactsRelationships.IsWork,
    Primary = true,
    Street = localContact.Address,
    City = localContact.City,
    Region = localContact.State,
    Postcode = (localContact.Pincode == 0) ? string.Empty : localContact.Pincode.ToString(),
});
contact.Content = localContact.Note;

//code of update existing contact
Google.Contacts.Contact updatedContact = contactRequest.Update(contact);

有人可以建议我在这里缺少什么吗?

0 个答案:

没有答案