I have an Apps script when run:
reads Google sheet,adds new contact/s ( name and email) into Google Contacts,a duplicate is prevented to be entered into Google contacts as well.
However, I want when any contact email removed from the google sheet ( column B), the contact from Google Contacts to be removed as well(email and name).the spreadsheet has 3 columns:A: timestamp, B: email, C: name
Is anyone willing to help me with the script, please?I appreciate your help.
Here is what I got:
function myFunction11() { var sheet = SpreadsheetApp.getActive().getSheetByName("sheet1"); //Iterate through your spreadsheet for (var i = 0; i < sheet.getLastRow()-1; i++) { var contactEmail = sheet.getRange(i+2,2,1,2).getValue(); var myContact = ContactsApp.getContact(contactEmail); if (myContact === null){ ContactsApp.createContact(sheet.getRange(i+2,3,1,2).getValue(),"",sheet.getRange(i+2,2,1,2).getValue()); } } }