MailApp
“MailApp” is a function inside the Google sheets which allows us to email others and yourself. you can also automate emails by using mail app function of Google Apps scripts. you can directly send emails from your workspace.” MailApp
” provides a powerful and flexible way to incorporate email functionality into your Google Apps Script projects.
Different Methods of using MailApp
There are various methods of using MailApp there are following syntax you can use to write Emails.
sendEmail(recipient, subject, body)
There are three parameters given you can write the receivers email address in recipient part then write the purpose of writing the mail at the end write the message in the body.
function EmailExample() {
var recipient = "recipient@example.com";
var subject = "Congratulations";
var body = "Hello, How are you? I just want to congratulates you.";
MailApp.sendEmail(recipient, subject, body);
}
sendEmail(recipient, subject, body, options)
There are four parameters given you can write the receivers email address in recipient part then write the purpose of writing the mail at the end write the message in the body. And you can add attachments files in the option part.
function sendEmail() {
var recipient = "recipient@example.com";
var subject = "Test Email";
var body = "This is a test email sent from Google Apps Script.";
var options = {
cc: "cc@example.com",
bcc: "bcc@example.com",
htmlBody: "<p>This is a test email sent from <b>Google Apps Script</b>.</p>"
};
MailApp.sendEmail(recipient, subject, body, options);
}
sendEmail(message)
There is only one parameter you can Sends an email using an email message object.
getRemainingDailyQuota()
method returns the number of remaining email messages that the script project can send for the current day.
function checkQuota() {
var remainingQuota = MailApp.getRemainingDailyQuota();
Logger.log(“Remaining daily email quota: ” + remainingQuota);
}
you can send emails on daily bases by using taggers to automate your mails