function sendMailWatchlist() {
var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("WATCH"); //This is getting the sheet you want.
var sellorhold = sheet.getRange("H2:H16"); //This is the range which you are checking for a TRUE out of your companies. It is currently looking through rows 2 to 30 in column F. Can modify to suit needs.
var names = sheet.getRange("c2:d16");//Gets the names of all companies
var sellorholdValues = sellorhold.getValues(); // Gets the values from range ("TRUE" or "FALSE")
var nameValues = names.getValues(); // Gets the values of the company names.
var message = "";
var goodBuyList = [];
var yourName = "Vrock"
var yourEmailAddress = "vroc...@Gmail.com"
//Looping through range of companies and storing ones with TRUE signal in a array called goodBuyList
for (var i=0; i<sellorholdValues.length; i++){
if(sellorholdValues[i] == "Buy"){
goodBuyList.push(nameValues[i]); }
}
//Send Email
message = "Hi " +yourName + ",\nThe following stock(s) from your WATCHLIST are in the BUY & Near-Buy range:\n"; //Trying to make email look nice.
for(var i=0; i<goodBuyList.length; i++){message+="\n" + goodBuyList[i]}
message +="\n";
message += "\nGood luck" +yourName;
var subject = 'Watchlist Update!';
GmailApp.sendEmail("vroc...@Gmail.com", subject, message); //how Gmail App works: put email, subject then message. This end the email.
}
if(sellorholdValues[i] == "Buy"){
To:
if((sellorholdValues[i] == "Buy") || (sellorholdValues[i] == "Near Buy")){
--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/057150f7-4f16-48ab-b535-f0067eb40aden%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/bddd60cb-0361-4188-a30f-a2d5fc773a5cn%40googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/258e1660-5f8e-439d-95f9-519aa2e57a3bn%40googlegroups.com.
Dear investor,
Please find below the update on your portfolio:
LIST #1: SELL LIST
LIST #3: APPROACHING STOPLOSS
All the best.
=======================================================
The name of the stock and the current price is currently in Column C & E respectively in Google Spreadsheet. Thanks again for your help.
Best wishes,
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/0e8011a0-acc9-47ae-aa14-14a11d0ac93en%40googlegroups.com.