使用谷歌驱动器脚本发送包含表单提交照片的确认电子邮件

时间:2012-10-19 01:12:05

标签: google-apps-script

我为邮件列表创建了一个表单。该表单还有一个非常常见的脚本,在表单提交时向用户发送确认电子邮件

到目前为止我的代码:

function formSubmitReply(e) {
  var userEmail = e.values[2];
  MailApp.sendEmail(userEmail, 
                    "Insider emails", 
                    "Thanks for registering for our mailing list.",                    
                    {name:"Blah"});
}​

我会使用哪些代码在电子邮件正文中插入优惠券图片?

1 个答案:

答案 0 :(得分:3)

文档中的示例

function inlineImage() {
  var googleLogoBlob = UrlFetchApp.fetch("http://www.google.com/intl/en_com/images/srpr/logo3w.png").getBlob().setName("googleLogoBlob");
  var youtTubeLogoBlob = UrlFetchApp.fetch("http://s.ytimg.com/yt/img/logos/youtube_logo_standard_againstwhite-vflKoO81_.png").getBlob().setName("youtTubeLogoBlob");

  MailApp.sendEmail(
    "sg.appsscript@gmail.com",
    "Logos",
    "", 
    { htmlBody: 
         "inline Google Logo<img src='cid:googleLogo'> images! <br/> inline YouTube Logo <img src='cid:youTubeLogo'>",
     inlineImages: 
         { googleLogo: googleLogoBlob,
           youTubeLogo:youtTubeLogoBlob
          }
    }

    );
}

请参阅:https://developers.google.com/apps-script/class_gmailapp#sendEmail