This is the legacy documentation for Google Ads scripts. Go to the current docs.

MailApp

Send a simple email

function sendSimpleTextEmail() {
  MailApp.sendEmail('INSERT_EMAIL_HERE',
                    'TPS reports',
                    'Where are the TPS reports?');
}

Send email with attachments

function sendEmailWithAttachments() {
  var fileId = '0B41tKrRQJmxeQXlsQUVkMzNxN28';
  // Send an email with two attachments: a file from Google Drive (as a PDF)
  // and an HTML file.
  var file = DriveApp.getFileById(fileId);
  var blob = Utilities.newBlob('Insert any HTML content here', 'text/html',
                               'my_document.html');
  MailApp.sendEmail('INSERT_EMAIL_HERE', 'Attachment example',
                    'Two files are attached.',
                    {
                        name: 'Automatic Emailer Script',
                        attachments: [file.getAs(MimeType.PDF), blob]
                    });
}

Send HTML email with images

function sendHtmlEmailWithInlineImage() {
  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: 'INSERT_EMAIL_HERE',
    subject: 'Logos',
    htmlBody: "inline Google Logo<img src='cid:googleLogo'> images! <br>" +
              "inline YouTube Logo <img src='cid:youtubeLogo'>",
    inlineImages:
      {
        googleLogo: googleLogoBlob,
        youtubeLogo: youtubeLogoBlob
      }
  });
}