AviEzerzer

Untitled

Sep 5th, 2019
414
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function Importcontacts() {
  2.     var contacts = ContactsApp.getContacts(); // Fetches contact list of group
  3.     var ss = SpreadsheetApp.getActiveSpreadsheet(); //Get currently Active sheets
  4.     var sheet = ss.getSheets()[0]; //Get first from active sheets list
  5.     sheet.appendRow(['Full Name', 'Email Address']); // Creating Header
  6.     for (var i in contacts) {
  7.         var contact = contacts[i];
  8.         var id = contact.getId(); //get contact id
  9.         var fullname = contacts[i].getFullName(); // gets full name of contact
  10.         var emailid = contacts[i].getEmails(); //get emailid of contact
  11.         for (i in emailid) {
  12.             sheet.appendRow([id, fullname, emailid[i].getAddress()]); // append contact data to active sheet
  13.         }
  14.     }
  15.  
  16.     var contact2 = ContactsApp.getContactsByName('firstname2 lastname2')
  17.     for (var i in contact2) {
  18.         contact2[i].setFamilyName('Doe-Smith');
  19.     }
  20.  
  21. }
  22.  
  23. function getContact(id) {
  24.     return ContactsApp.getContactById(id);
  25. }
  26.  
  27. //var contact1 = getContact('http://www.google.com/m8/feeds/contacts/testgranot%40gmail.com/base/7b48cd3b0a764f43');
  28. //
  29. //Logger.log(
  30. //    contact1.getFullName()
  31. //);
  32. //
  33. //Logger.log(
  34. //    ContactsApp.getContact('[email protected]').setFamilyName('Doe-Smith')
  35. //);
Advertisement
Add Comment
Please, Sign In to add comment