https://developers.google.com/apps-script/reference/mail/mail-app
Sending a simple email:
Original version:
function myFunction10() {
MailApp.sendEmail({
to: 'mymail@gmail.com', // Recipient's email address
subject: 'Subject of the email',
body: "Line 1\r\nLine 2\r\nLine 3", // Email content
});
My version with changes or enhancements:
function sendingSimpleEmail() {
MailApp.sendEmail({
to: 'darja.suhhanova@gmail.com',
subject: 'Test',
body: "Hello,\r\World\r\!",
});
}
Sending an email with an attached file:
Original version:
// 1bPpy2Mm7sAffcZwSvuxOooPfrhfEWuE2 - ID of the PDF file stored on Google Drive
var pdfFileBlob = DriveApp.getFileById( '1bPpy2Mm7sAffcZwSvuxOooPfrhfEWuE2' ).getBlob();
MailApp.sendEmail({
to: 'mymail@gmail.com', // Recipient's email address
subject: 'Subject of the email 2',
body: "Line 1\r\nLine 2\r\nLine 3", // Email content
// Attach the file
attachments: [pdfFileBlob]
});
}
My version with changes or enhancements:
function sendingEmailWithFile() {
var pdfFileBlob = DriveApp.getFileById( '1WoONxmLIqfqAAOaxFXZvrWN9ns66VYPnKsk8idhFVAA' ).getBlob();
MailApp.sendEmail({
to: 'darja.suhhanova@gmail.com',
subject: 'Test',
body: "Line 1\r\nLine 2\r\nLine 3",
attachments: [pdfFileBlob]
});
}


