Google App Script未设置Bcc地址

时间:2016-11-30 15:02:44

标签: google-apps-script

我开发了一个简单的谷歌应用脚​​本来发送带有密件抄送的电子邮件我只是尝试URL参数To,From和subject设置正确但是,cc和密件抄送地址设置不正确

enter image description here

我的代码段就在这里。

function doPost(e) { // change to doPost(e) if you are recieving POST data
var mailId = '';
var mailSubject = '';
var mailBody = '';
var htmlBody = '';
var senderName = '';
var replyToAddress = '';
var bccAddresses = '';

    mailId = e.parameter['Email'];
    mailSubject = e.parameter['Subject'];
    mailBody = e.parameter['MailBody'];
    htmlBody = e.parameter['HtmlBody'];
    senderName = e.parameter['SenderName'];
    replyToAddress = e.parameter['ReplyTo'];
    bccAddresses = e.parameter['bccAddress'];

  Logger.log(':::::::mailId:::::',mailId);

  if(mailId != '' && mailId != null){

    MailApp.sendEmail({
      to:mailId, 
      subject:mailSubject, 
      htmlBody:mailBody, 
      bcc:bccAddresses,
      name:senderName,
      replyTo:replyToAddress,
    });  
  }

var emailQuotaRemaining = MailApp.getRemainingDailyQuota();
return ContentService
            .createTextOutput(emailQuotaRemaining);
}

function doGet(request) {
  var emailQuotaRemaining = MailApp.getRemainingDailyQuota();
  var result = {
    available: 0
  };
  return ContentService.createTextOutput(
    request.parameters.prefix + '(' + emailQuotaRemaining + ')')
    .setMimeType(ContentService.MimeType.JAVASCRIPT);
}

我的HTML代码是

<form method="post" style="display:none;" id="form" action="https://script.google.com/macros/s/AKfycbwlMz27gP9vxZA-X58wvxgerhG46A6TEZw33YFe5mvJ0ejFSYQt/exec">
        <input type="text" name="Subject" value="Test Subject" />
        <input type="text" name="MailBody" value="Test Body" />
        <input type="text" name="Email" value="subashc@softsquare.biz" />
        <input type="text" name="SenderName" value="MSCB" />
        <input type="text" name="ReplyTo" value="test@gmail.com" />
        <input type="text" name="bccAddress" value="mscb39@yahoo.com" />
        <textarea name="HtmlBody">Test Body</textarea>
        <input type="submit" id="sub" />
    </form>  
    <button onclick="subForm();">Submit</button>

    <script>
        function subForm() {
            document.getElementById('form').submit();
        }
    </script>

先谢谢,

Subash Chandrabose.M

2 个答案:

答案 0 :(得分:1)

你能把BCC放在选项和测试中吗。

MailApp.sendEmail(to, subject, "", {
  htmlBody:mailBody, 
  bcc:bccAddresses,
  name:senderName,
  replyTo:replyToAddress
});  

答案 1 :(得分:0)

当你打电话给你的功能时,似乎你没有恢复bcc地址..你怎么称呼你的功能? (我会评论,但我还没有足够的声誉)