How to send an automated email via Google Script?

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 wi…


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:

  1. Go to script.google.com and sign in with your Google account.

  2. Click on the "New script" button. This will create a new blank script for you.

  3. 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);
}
  1. Replace "youremail@example.com" with the email address you want to send the email to.

  2. Replace "This is the subject of the email" with the subject of the email you want to send.

  3. Replace "This is the body of the email" with the body of the email you want to send.

  4. Save the script by clicking on the "File" menu and then selecting "Save".

  5. Test the script by clicking on the "Run" menu and then selecting "sendEmail". This will send an email to the email address you specified.

  6. 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


Print Share Comment Cite Upload Translate Updates
APA

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/

MLA
" » How to send an automated email via Google Script?." Shiva Aryal | Sciencx - Friday January 13, 2023, https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/
HARVARD
Shiva Aryal | Sciencx Friday January 13, 2023 » How to send an automated email via Google Script?., viewed ,<https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/>
VANCOUVER
Shiva Aryal | Sciencx - » How to send an automated email via Google Script?. [Internet]. [Accessed ]. Available from: https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/
CHICAGO
" » How to send an automated email via Google Script?." Shiva Aryal | Sciencx - Accessed . https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/
IEEE
" » How to send an automated email via Google Script?." Shiva Aryal | Sciencx [Online]. Available: https://www.scien.cx/2023/01/13/how-to-send-an-automated-email-via-google-script/. [Accessed: ]
rf:citation
» How to send an automated email via Google Script? | Shiva Aryal | Sciencx | 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.

You must be logged in to translate posts. Please log in or register.