0
votes

I tried the following code to set birthday for a contact in Gmail. It says cannot setDate of undefined. What am i doing wrong?

var contacts = ContactsApp.getContactsByName('John Doe');
var birthday = contacts[0].getDates(ContactsApp.Field.BIRTHDAY)[0];
birthday.setDate(ContactsApp.Month.APRIL, 1, 1980);
1

1 Answers

1
votes

Once again the autocomplete feature helped me to find the solution...

try like this :

function myFunction() {
  var contacts = ContactsApp.getContactsByName('John Doe');
  var contact = contacts[0];
  contact.addDate(ContactsApp.Field.BIRTHDAY,ContactsApp.Month.FEBRUARY,19,1958);
}

John Doe was born on february hte 19, 1958... just like me ! what a coincidence 8-)