简体   繁体   中英

Google Apps Script - MailApp

I want to send an email with replyTo and attachments using Google Apps Script, but I only found those two methods, that do what I want separately.

sendEmail(recipient, subject, body, options)

sendEmail(to, replyTo, subject, body)   

There's another method which I can do both?

Your best bet would be to use the first method of

sendEmail(recipient, subject, body, options)

This method can take all of your parameters. You pass all of your parameters in the options part.

It will look something like this.

// Send an email with two attachments:
//   a file from Google Drive (as a PDF) and an HTML file.
var file = DriveApp.getFileById('12345mnopqrstuvwxyz');
var blob = Utilities.newBlob('HTML content here',
                             'text/html',
                             'my_email.html');

MailApp.sendEmail('mike@example.com',
                  'Attachment example',
                  'Two files are attached.',
                  {
                    attachments: [file.getAs(MimeType.PDF), blob],
                    replyTo: 'ReplyTo@Email.com'
                  });

here is a screenshot of the documentation

谷歌文档图片

Google documentation here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM