Google Apps Script - MailApp

I want to send an email with responses in apps and apps using Google Apps Script, but I only found these two methods that do what I want separately.

sendEmail(recipient, subject, body, options)

sendEmail(to, replyTo, subject, body)   

      

Is there another method I can do like?

+3


source to share


1 answer


It is best to use the first method

sendEmail(recipient, subject, body, options)

      

This method can accept 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

+4


source







All Articles