简体   繁体   English

通过按 googlesheet 中的按钮获取邮件 ID

[英]Take mail ID by pressing a button in googlesheet

Can someone suggest me a Google Script that will make a button that will get the mail ID of the person and put it into a specified Google sheet.有人可以向我推荐一个 Google 脚本,该脚本将制作一个按钮,该按钮将获取此人的邮件 ID 并将其放入指定的 Google 表格中。

This would be your script.这将是您的脚本。 Create a drawing like a button, via the little 3 dots you can assign it to a script, type: getEmail.创建一个像按钮一样的绘图,通过三个小点,您可以将其分配给脚本,输入:getEmail。

If the user is a gmail user it will append the value to the target sheet.如果用户是 gmail 用户,它将 append 的值到目标表。 If not then it opens a prompt where someone can enter the email.如果没有,那么它会打开一个提示,有人可以在其中输入 email。

function getEmail(){
  const ui = SpreadsheetApp.getUi();
  const ss = SpreadsheetApp.getActiveSpreadsheet();
  const targetSheet = ss.getSheetByName("targetsheet"); // change to desire
  const userMail = Session.getActiveUser().getEmail();

  if (userMail == null){
    targetSheet.appendRow(ui.prompt("Enter email").getResponseText());
  } else {
    targetSheet.appendRow([userMail]);
  }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM