如何使用Google脚本通过群组帐户发送电子邮件 [英] How to use Google Script Send email with group account

查看:68
本文介绍了如何使用Google脚本通过群组帐户发送电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Google Script发送电子邮件,但是我需要使用公共(组)邮箱,

I want to send an email with Google Script, but I need to use the public (group) mailbox,

我找不到在Google API上从群组帐户发送电子邮件的示例,并且在堆栈溢出时也找不到答案.您能告诉我是否有一种使用Google脚本通过群组帐户发送电子邮件的方法吗?

I didn't find an example of sending email from the group account on the Google API, and I couldn't find the answer on the stack overflow. Could you please tell me if there is a method that use google script send email with group account?

推荐答案

我已经解决了这个问题.从帐户和导入"中添加您的群组帐户,然后您可以参考以下代码来测试是否可以在群组帐户中发送电子邮件.

I have solved the problem. from "Account and import" add your group account then You can reference below code to test whether you can send an email in group account.

  var alias = GmailApp.getAliases();
  var num = alias.length-1;
  var myMail = getMyMail();

  if (num<0){
    return false
  }else{
    for (var i = 0;i <= num;i++){
      if (alias[i] == "yourGroup@Domain.com"){
        var myGroupMail=alias[i];
        break;
      }
    }
  }
  if (myGroupMail != "yourGroup@Domain.com"){return false}
  GmailApp.sendEmail(toEmail,strSubject,strContent,{from : myGroupMail});

这篇关于如何使用Google脚本通过群组帐户发送电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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