메일을 보내야하는 일정 및 수신자 배열이 있습니다. 그때 나는 다른 해결책은있다, 난이 PARAMS (받는 사람)google-app-script에서 트리거 된 함수에 매개 변수를 전달하는 방법
function send_mail(recipients)
{
var id = DocumentApp.getActiveDocument().getId();
for(i=0;i<recipients.length;i++)
{
var url = "https://docs.google.com/feeds/download/documents/export/Export?id="+id+"&exportFormat=html";
var param =
{
method : "get",
headers : {"Authorization": "Bearer " + ScriptApp.getOAuthToken()},
muteHttpExceptions:true,
};
var html = UrlFetchApp.fetch(url,param).getContentText();
var raw = Utilities.base64EncodeWebSafe("Subject: Test\r\n" +
"To:" +recipients[i]+"\r\n" +
"Content-Type: text/html; charset=UTF-8\r\n\r\n" +
html+"\r\n\r\n");
var message = Gmail.newMessage();
message.raw = raw;
var sentMsg = Gmail.Users.Messages.send(message, recipients[i]);
}
}
function schedule_mail(recipients,schedule)
{
ScriptApp.newTrigger("send_mail").timeBased().at(schedule).create();
}
PARAMS는 시간 기반 트리거에 전달 될 수없는 경우를 통과 할 수있는에 트리거를 만들기 위해 어떻게든지있을 경우 아는 열망?
트리거에 매개 변수를 전달할 수 있다고 생각하지 않습니다. [PropertiesService] (https://developers.google.com/apps-script/reference/properties/properties-service) 사용을 고려해 보셨습니까? –
PropertiesService에 변수를 저장하는 경우 트리거를 관리하는 방법 (트리거를 작성해야 할 때와 실행 후 트리거를 삭제하는 방법) @ Pierre-MarieRichard –
트리거를 생성하고 변수를 PropertiesService에 저장합니다. 그런 다음 함수에 코드를 추가하여 PropertiesService에서 변수를 가져올 수 있습니다. 함수가 완료되면 트리거를 지 웁니다. function delTrigger() { var triggers = ScriptApp.getProjectTriggers(); for (var i = 0; i