-
Notifications
You must be signed in to change notification settings - Fork 40
/
sendMail.gs
49 lines (46 loc) · 1.04 KB
/
sendMail.gs
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
41
42
43
44
45
46
47
48
49
// function test_sendMail() {
// var set = {
// do: true,
// to: '[email protected]',
// subject: 'Test #1. ⚔️💀 Kill me',
// body:
// "<p><b>This text is bold</b></p>" +
// "<p><i>This text is italic</i></p>" +
// "<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>"
// };
// var res = sendMail_(set);
// console.log(res);
// }
function sendMail_(set) {
// ##1. Checks
if (!set.do) {
console.log('task was set: not to do');
return -1;
}
if (!set.subject || set.subject==='') {
console.log('subject is empty');
return -2;
}
if (!set.body || set.body==='') {
console.log('body is empty');
return -3;
}
if (!set.to || set.to==='') {
console.log('to is empty');
return -4;
}
// ##2. Send
MailApp.sendEmail(
set.to,
set.subject,
'',
{htmlBody: set.body}
);
console.log('sent email');
return 0;
}
function getRemainingDailyMailQuota() {
var quota = MailApp.getRemainingDailyQuota();
console.log(quota);
return quota;
}