This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Shiva Aryal
To send an automated email via Google Script, you will need to do the following:
Go to script.google.com and sign in with your Google account.
Click on the "New script" button. This will create a new blank script for you.
Replace the existing code with the following code:
function sendEmail() {
var email = "youremail@example.com";
var subject = "This is the subject of the email";
var body = "This is the body of the email";
MailApp.sendEmail(email, subject, body);
}
Replace "youremail@example.com" with the email address you want to send the email to.
Replace "This is the subject of the email" with the subject of the email you want to send.
Replace "This is the body of the email" with the body of the email you want to send.
Save the script by clicking on the "File" menu and then selecting "Save".
Test the script by clicking on the "Run" menu and then selecting "sendEmail". This will send an email to the email address you specified.
You can also use this script to send emails to multiple recipients by separating the email addresses with a comma, like this:
var email = "youremail@example.com, anotheremail@example.com";
You can also customize the email further by using the various options available in the MailApp.sendEmail() function. For example, you can add attachments to the email, specify a reply-to address, or set the name of the sender. You can find more information about these options in the Google Scripts documentation.
This content originally appeared on DEV Community 👩‍💻👨‍💻 and was authored by Shiva Aryal
Shiva Aryal | Sciencx (2023-01-13T15:32:23+00:00) How to send an automated email via Google Script?. Retrieved from https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.