amadev
amadev

Reputation: 41

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?

Upvotes: 2

Views: 366

Answers (1)

erick barreat
erick barreat

Reputation: 186

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('[email protected]',
                  'Attachment example',
                  'Two files are attached.',
                  {
                    attachments: [file.getAs(MimeType.PDF), blob],
                    replyTo: '[email protected]'
                  });

here is a screenshot of the documentation

Google Documentation Image

Google documentation here

Upvotes: 5

Related Questions