Created
July 29, 2019 13:19
-
-
Save ljhaywar/21be49d65e4f482fb9d95cc3beaee3c9 to your computer and use it in GitHub Desktop.
Intro to MongoDB Stitch Video 5: EmailAboutComment
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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