Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function Importcontacts() {
- var contacts = ContactsApp.getContacts(); // Fetches contact list of group
- var ss = SpreadsheetApp.getActiveSpreadsheet(); //Get currently Active sheets
- var sheet = ss.getSheets()[0]; //Get first from active sheets list
- sheet.appendRow(['Full Name', 'Email Address']); // Creating Header
- for (var i in contacts) {
- var contact = contacts[i];
- var id = contact.getId(); //get contact id
- var fullname = contacts[i].getFullName(); // gets full name of contact
- var emailid = contacts[i].getEmails(); //get emailid of contact
- for (i in emailid) {
- sheet.appendRow([id, fullname, emailid[i].getAddress()]); // append contact data to active sheet
- }
- }
- var contact2 = ContactsApp.getContactsByName('firstname2 lastname2')
- for (var i in contact2) {
- contact2[i].setFamilyName('Doe-Smith');
- }
- }
- function getContact(id) {
- return ContactsApp.getContactById(id);
- }
- //var contact1 = getContact('http://www.google.com/m8/feeds/contacts/testgranot%40gmail.com/base/7b48cd3b0a764f43');
- //
- //Logger.log(
- // contact1.getFullName()
- //);
- //
- //Logger.log(
- // ContactsApp.getContact('[email protected]').setFamilyName('Doe-Smith')
- //);
Advertisement
Add Comment
Please, Sign In to add comment