-
Notifications
You must be signed in to change notification settings - Fork 0
/
daysleft.js
40 lines (39 loc) · 1000 Bytes
/
daysleft.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
var AWS = require('aws-sdk');
var ses = new AWS.SES({'region': 'us-east-1'});
var daysleft = Math.trunc((Date.parse("2017-09-13 00:00 PST+0700")-Date.now())/(1000*60*60*24));
var params = {
Source: "[email protected]",
Destination: {
BccAddresses: [],
CcAddresses: [],
ToAddresses: [
]
},
Message: {
Body: {
Html: {
Charset: "UTF-8",
Data: "<h1>" + daysleft + "</h1><p>days left to demo day</p>"
},
Text: {
Charset: "UTF-8",
Data: daysleft + " days left to demo day."
}
},
Subject: {
Charset: "UTF-8",
Data: daysleft + " Days Left"
}
}
};
console.log('===SENDING EMAIL===');
ses.sendEmail(params, function(err, data) {
if (err) console.log(err, err.stack); // an error occurred
else {
console.log("===EMAIL SENT===");
console.log(data); // successful response
}
});