Google Apps 脚本 - MailApp

ama*_*dev 3 google-apps-script

我想使用 Google Apps Script 发送一封带有回复和附件的电子邮件,但我只找到了这两种方法,分别做我想做的事。

sendEmail(recipient, subject, body, options)

sendEmail(to, replyTo, subject, body)   
Run Code Online (Sandbox Code Playgroud)

还有另一种方法可以同时做到吗?

小智 5

最好的办法是使用第一种方法

sendEmail(recipient, subject, body, options)
Run Code Online (Sandbox Code Playgroud)

此方法可以采用您的所有参数。您在选项部分传递所有参数。

它看起来像这样。

// 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'
                  });
Run Code Online (Sandbox Code Playgroud)

这是文档的屏幕截图

谷歌文档图片

谷歌文档在这里