2

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('someemail@email.com'), though.

Thanks for any clarification.

Antonio

onit
  • 2,275
  • 11
  • 25

1 Answers1

2

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('someemail@email.com') 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.

Reference:

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • It did point me to the right direction. Thank you! Ended up using: ```var emailResp = ContactsApp.getContactsByEmailAddress(email); var emails= emailResp[0].getEmails(); var emailAddress = String(contactEmail.map(e => e.getAddress()));``` – onit Nov 18 '21 at 12:21
  • 1
    @Antonio Santos Thank you for replying. I'm glad your issue was resolved. Thank you, too. – Tanaike Nov 19 '21 at 00:07