Advertisement
AviEzerzer

Untitled

Sep 5th, 2019
151
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 fullname = contacts[i].getFullName(); // gets full name of contact
  8.         var emailid = contacts[i].getEmails(); //get emailid of contact
  9.         for (i in emailid) {
  10.             sheet.appendRow([fullname, emailid[i].getAddress()]); // append contact data to active sheet
  11.         }
  12.     }
  13. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement