Google script trigger to run only on Monday/Wednesday/Friday











up vote
0
down vote

favorite












I'm running a SendEmail script with a 3 triggers to be sent out on Mondays, Wednesdays and Fridays.



I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)



This is the code:



function sendEmail() {
var s = SpreadsheetApp.getActive().getSheetByName('BCX');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveSheet().getDataRange();
var range = s.getRange('B5:Q20');
var row = ss.getSheetByName('BCX').getRange("J1").getValue();
var to = "info@google.com";
var body = '';
var htmlTable = SheetConverter2.convertRange2html(range);
var body = "Hi Team!"
+ htmlTable
+ "<br/><br/><b><i>**This is an automated email**</i></b><br/><br/>Any question please let me know.<br/><br/>Regards,<br/><br/>";
var subject = "Google | Report " + row;

MailApp.sendEmail(to, subject, body, {htmlBody: body});
};


But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).



function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY,
ScriptApp.WeekDay.WEDNESDAY,
ScriptApp.WeekDay.FRIDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger("sendEmail")
.timeBased().onWeekDay(days[i])
.atHour(7).create();
}
};









share|improve this question




















  • 1




    I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
    – Tanaike
    Nov 19 at 23:45










  • I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
    – Juan Pablo Marroquin Ocampo
    Nov 21 at 17:56










  • I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
    – Tanaike
    Nov 21 at 23:36










  • Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
    – Juan Pablo Marroquin Ocampo
    Nov 23 at 0:58










  • Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
    – Tanaike
    Nov 23 at 2:21















up vote
0
down vote

favorite












I'm running a SendEmail script with a 3 triggers to be sent out on Mondays, Wednesdays and Fridays.



I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)



This is the code:



function sendEmail() {
var s = SpreadsheetApp.getActive().getSheetByName('BCX');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveSheet().getDataRange();
var range = s.getRange('B5:Q20');
var row = ss.getSheetByName('BCX').getRange("J1").getValue();
var to = "info@google.com";
var body = '';
var htmlTable = SheetConverter2.convertRange2html(range);
var body = "Hi Team!"
+ htmlTable
+ "<br/><br/><b><i>**This is an automated email**</i></b><br/><br/>Any question please let me know.<br/><br/>Regards,<br/><br/>";
var subject = "Google | Report " + row;

MailApp.sendEmail(to, subject, body, {htmlBody: body});
};


But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).



function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY,
ScriptApp.WeekDay.WEDNESDAY,
ScriptApp.WeekDay.FRIDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger("sendEmail")
.timeBased().onWeekDay(days[i])
.atHour(7).create();
}
};









share|improve this question




















  • 1




    I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
    – Tanaike
    Nov 19 at 23:45










  • I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
    – Juan Pablo Marroquin Ocampo
    Nov 21 at 17:56










  • I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
    – Tanaike
    Nov 21 at 23:36










  • Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
    – Juan Pablo Marroquin Ocampo
    Nov 23 at 0:58










  • Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
    – Tanaike
    Nov 23 at 2:21













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I'm running a SendEmail script with a 3 triggers to be sent out on Mondays, Wednesdays and Fridays.



I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)



This is the code:



function sendEmail() {
var s = SpreadsheetApp.getActive().getSheetByName('BCX');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveSheet().getDataRange();
var range = s.getRange('B5:Q20');
var row = ss.getSheetByName('BCX').getRange("J1").getValue();
var to = "info@google.com";
var body = '';
var htmlTable = SheetConverter2.convertRange2html(range);
var body = "Hi Team!"
+ htmlTable
+ "<br/><br/><b><i>**This is an automated email**</i></b><br/><br/>Any question please let me know.<br/><br/>Regards,<br/><br/>";
var subject = "Google | Report " + row;

MailApp.sendEmail(to, subject, body, {htmlBody: body});
};


But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).



function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY,
ScriptApp.WeekDay.WEDNESDAY,
ScriptApp.WeekDay.FRIDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger("sendEmail")
.timeBased().onWeekDay(days[i])
.atHour(7).create();
}
};









share|improve this question















I'm running a SendEmail script with a 3 triggers to be sent out on Mondays, Wednesdays and Fridays.



I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)



This is the code:



function sendEmail() {
var s = SpreadsheetApp.getActive().getSheetByName('BCX');
var ss = SpreadsheetApp.getActiveSpreadsheet();
var range = ss.getActiveSheet().getDataRange();
var range = s.getRange('B5:Q20');
var row = ss.getSheetByName('BCX').getRange("J1").getValue();
var to = "info@google.com";
var body = '';
var htmlTable = SheetConverter2.convertRange2html(range);
var body = "Hi Team!"
+ htmlTable
+ "<br/><br/><b><i>**This is an automated email**</i></b><br/><br/>Any question please let me know.<br/><br/>Regards,<br/><br/>";
var subject = "Google | Report " + row;

MailApp.sendEmail(to, subject, body, {htmlBody: body});
};


But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).



function createTriggers() {
var days = [ScriptApp.WeekDay.MONDAY,
ScriptApp.WeekDay.WEDNESDAY,
ScriptApp.WeekDay.FRIDAY];
for (var i=0; i<days.length; i++) {
ScriptApp.newTrigger("sendEmail")
.timeBased().onWeekDay(days[i])
.atHour(7).create();
}
};






javascript google-apps-script google-sheets






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Nov 23 at 0:57

























asked Nov 19 at 22:56









Juan Pablo Marroquin Ocampo

156




156








  • 1




    I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
    – Tanaike
    Nov 19 at 23:45










  • I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
    – Juan Pablo Marroquin Ocampo
    Nov 21 at 17:56










  • I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
    – Tanaike
    Nov 21 at 23:36










  • Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
    – Juan Pablo Marroquin Ocampo
    Nov 23 at 0:58










  • Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
    – Tanaike
    Nov 23 at 2:21














  • 1




    I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
    – Tanaike
    Nov 19 at 23:45










  • I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
    – Juan Pablo Marroquin Ocampo
    Nov 21 at 17:56










  • I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
    – Tanaike
    Nov 21 at 23:36










  • Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
    – Juan Pablo Marroquin Ocampo
    Nov 23 at 0:58










  • Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
    – Tanaike
    Nov 23 at 2:21








1




1




I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
– Tanaike
Nov 19 at 23:45




I cannot understand the logic of But if I use something like the following script it will create 3 triggers each week until it reaches 20 triggers (trigger limit).. When your createTriggers() is run, 3 triggers are created for running sendEmail every Monday, Wednesday and Friday as "Week timer". I think that when createTriggers() was run once, such trigger can be created. If I misunderstand your question, please tell me.
– Tanaike
Nov 19 at 23:45












I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
– Juan Pablo Marroquin Ocampo
Nov 21 at 17:56




I need the first script to run on Mondays, Wednesdays and Fridays for 10 sheets, that means 10 SendEmail scripts + 1 trigger for each day for each SendEmail script which trigger limitations doesnt allow more than 20
– Juan Pablo Marroquin Ocampo
Nov 21 at 17:56












I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
– Tanaike
Nov 21 at 23:36




I'm sorry for my poor English skill. I couldn't understand about what you want to do. You use 10 sheets in one Spreadsheet? Or you use 10 Spreadsheets? It seems that your script uses one sheet in one Spreadsheet. So can you update your question by including the detail information of the logic? Because in your question, By this, I think that it will help users understand your issue and think of your solution.
– Tanaike
Nov 21 at 23:36












Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
– Juan Pablo Marroquin Ocampo
Nov 23 at 0:58




Thank you Tanaike I have edited the question and yes, I have 10 sheets on the spreadsheet (each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation)
– Juan Pablo Marroquin Ocampo
Nov 23 at 0:58












Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
– Tanaike
Nov 23 at 2:21




Thank you for updating it. When you use 10 sheets in one Spreadsheet, I think that you can run a trigger by scanning each sheet. So I cannot understand the logic of each one contains an SentEmail script and each needs to be sent out on those days but I have only 20 trigger limitation. Can you explain about the detail of it? If my understanding of your situation is not correct, please tell me.
– Tanaike
Nov 23 at 2:21

















active

oldest

votes











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383834%2fgoogle-script-trigger-to-run-only-on-monday-wednesday-friday%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown






























active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes
















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53383834%2fgoogle-script-trigger-to-run-only-on-monday-wednesday-friday%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







Popular posts from this blog

To store a contact into the json file from server.js file using a class in NodeJS

Redirect URL with Chrome Remote Debugging Android Devices

Dieringhausen