Skip to content

Instantly share code, notes, and snippets.

@rishavk1102
Last active September 20, 2023 14:27
Show Gist options
  • Save rishavk1102/c487a31288e938af091a002210768f57 to your computer and use it in GitHub Desktop.
Save rishavk1102/c487a31288e938af091a002210768f57 to your computer and use it in GitHub Desktop.
Basic code to receive emails from SendGrid and display the email content.
const express = require('express')
const multer = require('multer')
const app = express()
const upload = multer()
app.post('/api/parse', upload.any(), async (req, res) => {
const body = req.body
console.log("to: ", body.to); // Receiver Email List
console.log("cc: ", body.cc); // CC Email List
console.log("from: ", body.from); // Sender Email
console.log("subject: ", body.subject); // Subject
console.log("text: ", body.text); // Email body in text
console.log("html: ", body.html); // Email body in HTML
console.log("attachments: ", body.attachments); // Attachment List of Email
console.log(req.files); // Attachment Files in Base64
return res.status(200).send();
});
app.listen(3000, () => {
console.log(`Webserver running on 3000`)
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment