Search code examples
google-apps-scriptgoogle-contacts-api

How to add a contact without a name in GAS?


I have a collection of contact info that I would like to add to Google Contacts via the ContactsApp. Is some cases this info is just an e-mail address without a name.

contact = ContactsApp.createContact("tmp1", "tmp2", "email");

The above doesn't seem to accept "" as an argument. Neither do the following:

contact.setGivenName(".");
contact.setFamilyName(":");
contact.setFullName("*");

I could use " ", but that is not ideal. Is there any way to have the names be "" just like when an e-mail address is saved from a gmail message sent without the name being available?


Solution

  • Just use null

    contact= ContactsApp.createContact(null,null,"email@somewhere.com");