按下Googlesheet中的按钮获取邮件ID [英] Take mail ID by pressing a button in googlesheet

查看:116
本文介绍了按下Googlesheet中的按钮获取邮件ID的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人可以向我建议一个Google脚本,该脚本将创建一个按钮,该按钮将获取该人的邮件ID并将其放入指定的Google表格中.

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.

推荐答案

这将是您的脚本.创建一个像按钮的图形,通过三个小点,您可以将其分配给脚本,键入:getEmail.

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.

如果用户是gmail用户,则会将值附加到目标工作表中.如果没有,那么它会打开一个提示,提示有人可以输入电子邮件.

If the user is a gmail user it will append the value to the target sheet. If not then it opens a prompt where someone can enter the 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]);
  }
}

这篇关于按下Googlesheet中的按钮获取邮件ID的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆