Although everything now runs, I only see logged [Contact], as it's returning an array. No documentation of how to get the email besides ContactsApp.getContacts ByEmailAdress('[email protected]')
, though.
Thanks for any clarification.
Antonio
CodePudding user response:
When the official document of getContactsByEmailAddress(query)
is seen, the returned value is Contact[]
. Unfortunately, although I cannot see your actual script for retrieving [Contact]
, I guessed that you might see the returned value with Logger.log
. If my understanding is correct, Logger.log(ContactsApp.getContactsByEmailAddress("### email address ###"))
show [Contact]
in the log.
I thought that this might be the answer for Why ContactsApp.getContacts ByEmailAdress('[email protected]') returns [Contact] using Google Apps Script?
.
If you want to retrieve the other data from the contact, how about the following sample script?
Sample script:
const res = ContactsApp.getContactsByEmailAddress("### email address ###");
// Logger.log(res) // In this case, `[Contact]` and `[Contact, Contact,,,]` can be seen.
const name = res.map(e => e.getFullName());
Logger.log(name) // In this case, as a sample, the full name is retrieved from the retrieved contact object.