使用Google Apps脚本在Gmail中创建用户别名 [英] Creating user aliases in gmail using google apps script

查看:66
本文介绍了使用Google Apps脚本在Gmail中创建用户别名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I am reading in alias email information from a google form entry and I wish to use it to create an alias email.

This link talks about using the directory API to accomplish this but from its description about setting up authorization etc. it seems to be for a web application.

How do I create an email alias for an account using a Google apps script associated with my Google Form?

解决方案

You can use the 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. In the Script Editor select Resources > Advanced Google services... and then enable it in the Google Developers Console.)

Once enabled you can add an alias like this:

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

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

Then you can verify the alias in your Admin Console in Users > Select User > Account > Aliases:

这篇关于使用Google Apps脚本在Gmail中创建用户别名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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