Skip to content

Instantly share code, notes, and snippets.

@ljhaywar
Created July 29, 2019 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ljhaywar/21be49d65e4f482fb9d95cc3beaee3c9 to your computer and use it in GitHub Desktop.
Save ljhaywar/21be49d65e4f482fb9d95cc3beaee3c9 to your computer and use it in GitHub Desktop.
Intro to MongoDB Stitch Video 5: EmailAboutComment
exports = function(changeEvent){
console.log("changeEvent: " + JSON.stringify(changeEvent));
const { fullDocument } = changeEvent;
console.log("full document " + JSON.stringify(fullDocument));
const ses = context.services.get("aws").ses();
var email = {
Destination: {
ToAddresses: [context.values.get("ToEmailAddress")]
},
Message: {
Body: {
Html: {
Data: "The comment is: " + fullDocument.comment
}
},
Subject: {
Data: "New comment on your blog post"
}
},
Source: context.values.get("FromEmailAddress")
};
try{
ses.SendEmail(email).then(function (result){
console.log("Email successfully sent: " + JSON.stringify(result));
});
} catch(error){
console.log("Error sending email: " + JSON.stringify(error));
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment