-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathForm Emailer
More file actions
34 lines (29 loc) · 1.03 KB
/
Form Emailer
File metadata and controls
34 lines (29 loc) · 1.03 KB
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
//Global Variables
var ss = SpreadsheetApp.getActiveSpreadsheet();
var tsSheet = ss.getSheetByName("Form");
var tsRows = parseInt(tsSheet.getLastRow());
var tsRange = tsSheet.getRange("G2:G"+tsRows);
var monitors = tsRange.getValues();
var monitorNeedsTagging = [];
var templateSheet = ss.getSheets()[1];
var emailTemplate = templateSheet.getRange("A1").getValue();
for (var i = 2; i < 200; i++) {
if(tsSheet.getRange("G" + i).getValue() == "none"){
monitorNeedsTagging.push(tsSheet.getRange("B" + i).getValue())
}
else{
}
}
monitorEmail();
function monitorEmail() {
for (var i = 0; i < monitorNeedsTagging.length; i++) {
var recipient="person@person.com"; // Who the email is sent to
var subject= monitorNeedsTagging[i] + " - Monitor Asset tag needed"; // Subject of the message
var message= monitorNeedsTagging[i] + "'s monitor needs an asset tag"; // Contents of the email
MailApp.sendEmail(recipient, subject, message);
Logger.log(subject);
};
}
function start() {
};
Logger.log(monitorNeedsTagging);