我试图让这个示例脚本从this Google Developer page开始工作。
我把以下代码复制/粘贴(除了" recipient@example.com"当然除外)到一个在提交表单时运行的函数。
// This code fetches the Google and YouTube logos, inlines them in an email
// and sends the email
function inlineImage() {
var googleLogoUrl = "http://www.google.com/intl/en_com/images/srpr/logo3w.png";
var youtubeLogoUrl = "https://developers.google.com/youtube/images/YouTube_logo_standard_white.png";
var googleLogoBlob = UrlFetchApp
.fetch(googleLogoUrl)
.getBlob()
.setName("googleLogoBlob");
var youtubeLogoBlob = UrlFetchApp
.fetch(youtubeLogoUrl)
.getBlob()
.setName("youtubeLogoBlob");
MailApp.sendEmail({
to: "recipient@example.com",
subject: "Logos",
htmlBody: "inline Google Logo<img src='cid:googleLogo'> images! <br>" +
"inline YouTube Logo <img src='cid:youtubeLogo'>",
inlineImages:
{
googleLogo: googleLogoBlob,
youtubeLogo: youtubeLogoBlob
}
});
}
根本不发送电子邮件,代码似乎无法执行。
当我删除前4个语句(设置URL和blob)以及sendEmail函数的inlineImages部分时,将发送电子邮件。
我做错了什么?