【问题标题】:Why ContactsApp.getContacts ByEmailAdress('someemail@email.com') returns [Contact] using Google Apps Script?为什么 ContactsApp.getContacts ByEmailAdress('someemail@email.com') 使用 Google Apps 脚本返回 [Contact]?
【发布时间】:2021-11-18 02:12:43
【问题描述】:

虽然现在一切都在运行,但我只看到记录的 [Contact],因为它正在返回一个数组。但是,除了ContactsApp.getContacts ByEmailAdress('someemail@email.com') 之外,没有关于如何获取电子邮件的文档。

感谢您的澄清。

安东尼奥

【问题讨论】:

    标签: google-apps-script google-sheets google-contacts-api


    【解决方案1】:

    看到getContactsByEmailAddress(query)的官方文档,返回值为Contact[]。不幸的是,虽然我看不到您检索[Contact] 的实际脚本,但我猜您可能会看到Logger.log 的返回值。如果我的理解是正确的,Logger.log(ContactsApp.getContactsByEmailAddress("### email address ###")) 在日志中显示[Contact]。

    我认为这可能是Why ContactsApp.getContacts ByEmailAdress('someemail@email.com') returns [Contact] using Google Apps 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.
    

    参考:

    【讨论】:

    • 它确实为我指明了正确的方向。谢谢!最终使用:var emailResp = ContactsApp.getContactsByEmailAddress(email); var emails= emailResp[0].getEmails(); var emailAddress = String(contactEmail.map(e => e.getAddress()));
    • @Antonio Santos 感谢您的回复。我很高兴你的问题得到了解决。也谢谢你。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-02-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-08-04
    • 1970-01-01
    相关资源
    最近更新 更多