Sending Emails with Gmail using API

Aditya Kumar - Oct 27 - - Dev Community

We're going to build an API that use Google App Script to send emails utilizing the Gmail API.

Github Code

Prerequisites

  • Basic JavaScript knowledge
  • Basic API knowledge
  • A Google Account

How to Build

  1. Open Google Sheets
  2. Now click on Blank Spreadsheet. Google forms home page
  3. This will create a Blank Spreadsheet. In my case I am naming it Email API.
  4. Now click on Extensions and then select Apps Script. Google form spreadheet
  5. Now it will open a code editor. Name your project if you want.app script code editor
  6. Copy and paste the code from Github. Press Ctrl + S to save the code.
  7. Click on Deploy, and then New Deployment. web app deployment

  8. Now Select Type and then Web App. deployment 1

  9. You have to fill some details here.

    • Description: Write anything you want
    • Executes as : Me (your email)
    • Who has access: Anyone
  10. After filling details click on Deploy and authorize application. deployment 2 deployment 3 deployment 4 deployment 5

  11. Now your project is deployed. Copy the URL and make a post request using postman or your project. deployed url

Make sure to include while making a POST request.

Content-Type: JSON

{
    "email":"",
    "subject":"",
    "body":""
}
Enter fullscreen mode Exit fullscreen mode

Thanks for reading!

.