开发者

Adding Contacts into particular group? Google Contact API

I am using Google Contact API to add Contacts and Groups into Google Apps (gmail). I am able to create Contact开发者_如何学运维s as well as Groups.

But now i want to:

  1. Put contact into particular group at the time of creation of Contact.


/* Get Group, this is covered in the Google Contact API documents */
/* http://code.google.com/apis/contacts/docs/2.0/developers_guide_dotnet.html#retrieving_single_group */

Group group = ...; 

Contact newContact = new Contact();

var groupMembership = new GroupMembership();
groupMembership.HRef= group.Id;


newContact.Title = "My google contact title";
newContact.GroupMembership.Add(groupMembership);

/* Save the contact, also covered in the documents */
/* http://code.google.com/apis/contacts/docs/2.0/developers_guide_dotnet.html#Creating */


Following worked for me:

Group g = cr.Retrieve<Group>(new Uri("https://www.google.com/m8/feeds/groups/liz%40gmail.com/base/68f415478ba1aa69"));

newEntry.GroupMembership.Add(new GroupMembership() { HRef = g.Id });
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜