Google apps script 需要帮助提取';电子邮件Id';在'中使用ContactsApp功能;谷歌脚本';
我已经编写了一个“谷歌脚本”,使用Google apps script 需要帮助提取';电子邮件Id';在'中使用ContactsApp功能;谷歌脚本';,google-apps-script,Google Apps Script,我已经编写了一个“谷歌脚本”,使用ContactsApp.getContactsByName函数提取“电子邮件地址”。我下面提到的脚本正在工作,但没有在“Google Sheet”的B列中给出任何输出 function test2() { var s = SpreadsheetApp.getActiveSheet(); var cell = s.getRange('a1'); for (var x = 1; x <= 15; x++) { var r = s.getRan
ContactsApp.getContactsByName
函数提取“电子邮件地址”。我下面提到的脚本正在工作,但没有在“Google Sheet”的B列中给出任何输出
function test2() {
var s = SpreadsheetApp.getActiveSheet();
var cell = s.getRange('a1');
for (var x = 1; x <= 15; x++) {
var r = s.getRange(x,1);
var b = r.getValue()
if(b)
var nextCell = r.offset(0, 1);
nextCell.setValue(ContactsApp.getContactsByName[b]);
}
}
更改2)
更改3)
如何编写正确的脚本?如果联系人有任何关联的电子邮件地址,getEmails()方法将返回一个数组。您需要对单个数组项调用getAddress(),以获取实际的电子邮件值
这里有一个简单的例子:
var contacts = ContactsApp.getContactsByName("name here");
var email = contacts[0].getEmails()[0].getAddress();
Logger.log(email);
谢谢阿米特的帮助
nextCell.setValue(ContactsApp.getContactsByName[b].getAddresses());
nextCell.setValue(ContactsApp.getContactsByName[b].getEmails().getAddresses());
var contacts = ContactsApp.getContactsByName("name here");
var email = contacts[0].getEmails()[0].getAddress();
Logger.log(email);