Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cotyembry/d48c4340b866853436bf3760f917d194 to your computer and use it in GitHub Desktop.
Save cotyembry/d48c4340b866853436bf3760f917d194 to your computer and use it in GitHub Desktop.
This is a .gs (google script) file that will fetch an image from a url using I suppose some of the Google Services APIs, converts that object to a BLOB, then sends the image to the email specified with the images inline within the email (This is so freaking cool - I tested it myself ^_^)
// 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: "yourEmail@somewhere.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
}
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment