Library for sending emails with Google Apps Script. Use MailApp
, GmailApp
or GmailAPI
. The library simpifies the usage of methods.
Library code is:
1XHgOqNIXoRxmM7StfIoxxqTVNoEVNpO46UsSSZdXZI4fezxCRIpSYHtB
🔗Source
If you would like to use Gmail API
, please enable it as advanced Google Service.
Please see how it works in a visual way:
- Copy ⚡ Automation Samples project file. Go to menu
File > Make a Copy
. - Change settings on the sheet:
_sendmail_
. - Use the menu
💌 Mail > 📮 Send Emails
to test the script. - Success: you'll send emails and see the logs in the last rows of sheet:
📜 logs
.
Please use this sample code with all possible settings:
function test_getMailApp() {
var options = {
to: '[email protected]', // required
cc: '[email protected]',
bcc: '[email protected],[email protected]',
name: '🎩Mad Hatter',
// from: '[email protected]', // for paid accounts + alias
subject: '🥸Test Test Test',
body: '💪 body!',
htmlBody: '<b>💪Bold Hello</b><br>How are you?',
noreply: 1,
replyto: '[email protected]',
// replytoname: 'Maaan', // works for Gmail API
// attachments: array,
// inlineimages: object
}
try {
// try using MailApp, or GmailApp
var response = MMailApp.send(options);
console.log(response);
} catch(err) {
console.log(err);
}
}
If you want to force the use of Gmail API:
// this will forse the use of Gmail API
MMailApp.sendGmailApi(options);
More info and all the links that helped me are posted in this article:
@max__makhrov