使用 google 应用程序脚本在 gmail 中创建用户别名

Creating user aliases in gmail using google apps script

我正在从 google 表单条目中读取别名电子邮件信息,我希望使用它来创建别名电子邮件。

This link 谈到使用目录 API 来完成此操作,但从其关于设置授权等的描述来看,它似乎是用于 Web 应用程序。

如何使用与我的 Google 表单关联的 Google 应用程序脚本为帐户创建电子邮件别名?

您可以使用Admin SDK's Directory API in Apps Script, but you need to use the Advanced Admin SDK Directory service (That must be enabled before use。在脚本编辑器中 select Resources > Advanced Google services... 然后在 Google Developers Console.)

启用后,您可以像这样添加别名:

function myFunction() {
  var userKey = 'jane.doe@mydomain.com';
  var resource = {
    alias: 'jenny@mydomain.com'
  }

  AdminDirectory.Users.Aliases.insert(resource, userKey)
}

然后您可以在管理控制台中的用户> Select用户>帐户>别名中验证别名: