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
      }
  });
}

发送以下问题的反馈:

此网页
AdWords Scripts
AdWords Scripts
需要帮助?请访问我们的支持页面