简体   繁体   中英

How to use Google Script Send email with group account

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

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});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM