检查非Google用户的addEditor(emailAddress)

时间:2018-01-10 17:19:51

标签: google-apps-script google-sheets

我已经能够使用addEditor(emailAddress)方法将编辑器添加到我的Google工作表中。这很棒。但是,我只想添加编辑器,如果提供的电子邮件连接到g-mail帐户。

在运行addEditor之前,工作表中是否有某种方法可以识别提供的电子邮件地址是否不是g-mail用户连接帐户?

1 个答案:

答案 0 :(得分:0)

Yes there is a way. Before executing addEditor(emailAddress) code block, write a filter on top to check if the email passed ends in @gmail.com.

Pseduocode:

if(emailAddress not_ends with @gmail.com){
  rejectemail..close program
}else if(emailAddress end with @gmail.com){
  addEditor(emailAddress)
}

You can use the endsWith() to filter the email addresses.