Search code examples
c#google-data-protocol

How to upload contacts CSV file to my Gmail account?


Just wondering whether it' s possible to upload a CSV file with contacts information in it to my Gmail account?

I already looked at the Google Data API. it only allows you to add one at a time. Is there a bulk import ?


Solution

  • My mistake, I found a method called Batch inside ContactsRequest class

                   newContact.Title = name;
                   newContact.Name.FullName = name;
    
                   EMail primaryEmail = new EMail(email);
                   primaryEmail.Primary = true;
                   primaryEmail.Rel = ContactsRelationships.IsWork;
                   newContact.Emails.Add(primaryEmail);
    
                   newContact.BatchData = new GDataBatchEntryData();
                   newContact.BatchData.Id = i.ToString();
                   newContact.BatchData.Type = GDataBatchOperationType.insert;
                   i ++;
                   list.Add(newContact);
    

    And then

               cr.Batch(list, new Uri(f.AtomFeed.Batch), GDataBatchOperationType.insert);