3
votes

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?

1

1 Answers

5
votes

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 Image

Google documentation here