Created
June 12, 2015 15:18
-
-
Save anonymous/b18ce3f49575c5a91938 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
laptopR = 2; | |
screenR = 3; | |
mandkR = 4; | |
mpR = 5; | |
gappsR = 6; | |
moffR = 7; | |
countColumn = 11; | |
function SupplyLevelEmail(e) | |
{ | |
try | |
{ | |
// Added code to allow it to read the spreadsheet | |
// this was taken from the previous script as we know it works | |
var sheet = SpreadsheetApp.getActiveSheet(); | |
var rows = sheet.getDataRange(); | |
var numRows = rows.getNumRows(); | |
var values = rows.getValues(); | |
var lr = rows.getLastRow(); | |
var s = SpreadsheetApp.getActiveSheet(); | |
var columns = s.getRange(1,1,1,s.getLastColumn()).getValues()[0]; | |
var laptopCount = sheet.getRange(laptopR,countColumn,1,1).getValue(); | |
var monitorCount = sheet.getRange(screenR,countColumn,1,1).getValue(); | |
var mandkCount = sheet.getRange(mandkR,countColumn,1,1).getValue(); | |
var phoneCount = sheet.getRange(mpR,countColumn,1,1).getValue(); | |
var gappsCount = sheet.getRange(gappsR,countColumn,1,1).getValue(); | |
var officeCount = sheet.getRange(moffR,countColumn,1,1).getValue(); | |
if (laptopCount||monitorCount||mandkCount||phoneCount||gappsCount||officeCount <3) { | |
messageArray = [ | |
('Laptops: '+laptopCount), | |
('Monitors: '+monitorCount), | |
('Mouse & Keyboards: '+mandkCount), | |
('Phones: '+phoneCount), | |
('Google Apps: '+gappsCount), | |
('Microsoft Office: '+officeCount) | |
] | |
var email = "[email protected]" | |
var replyto = "[email protected]"; | |
var subject = "Low Supply Count!" | |
var plainMessage = messageArray.join("\n\n"); | |
var htmlMessage = messageArray.join("<br><br>"); | |
} | |
MailApp.sendEmail({ | |
to: email, | |
replyTo : replyto, | |
subject: subject, | |
htmlBody: htmlMessage, | |
body: plainMessage | |
}); | |
// MailApp.sendEmail(email, replyto, subject, plainMessage); | |
} catch (e) { | |
Logger.log(e.toString()); | |
} | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment