ユーザーが Google フォームを送信し、最後のボックスにチェックを入れてコピーを受け取ると、適切にフォーマットされ、操作したフォーム ページのかなり簡潔な電子メール ビューが表示されます。onSubmit トリガーを使用して同じビューを生成するにはどうすればよいですか? 応答を得ることができますが、見栄えがよくありません。
助けてくれてありがとう、ボー
function formSubmit(event) {
var formResponse=event.response;
//Logger.log(formResponse);
var itemResponses = event.response.getItemResponses();
//Logger.log(itemResponses);
var editURL=event.response.getEditResponseUrl();
//Logger.log(editURL);
var emailSubject="***DO NOT REPLY***New Request has been submitted for "+formResponse.getRespondentEmail();
var emailBody="***DO NOT REPLY TO THIS MESSAGE***\nPLEASE REVIEW THE FULL FORM FOR ITEMS PERTAINING TO YOUR DEPARTMENT!!!"
var emailReplyTo="someemail@adomain.root"
var emailaddresses="someemail@adomain.root"
var DeploymentTeam="someemail@adomain.root"
var StoreTeam="someemail@adomain.root"
for (var j = 0; j < itemResponses.length; j++) {
var itemResponse = itemResponses[j];
var itemQuestion = itemResponse.getItem().getTitle();
var itemAnswer = itemResponse.getResponse();
//Logger.log(itemQuestion);
//Logger.log(itemAnswer);
//Add question and response to the body of the email. Exclude questions with no response.
if (itemAnswer != '') {
emailBody += "\n\n\n"+itemResponse.getItem().getTitle();
emailBody += "\n"+itemResponse.getResponse();
}
//BEGIN DEPLOYMENT TEAM TASKS
if (itemQuestion == 'What are you requesting?' && itemAnswer == 'I need servers rebuilt') {
emailaddresses += ",";
emailaddresses += DeploymentTeam;
}
if (itemQuestion == 'What are you requesting?' && itemAnswer == 'I need new software deployed') {
emailaddresses += ",";
emailaddresses += DeploymentTeam;
}
//END DEPLOYMENT TEAM TASKS
//BEGIN STORE TEAM TASKS
if (itemQuestion == 'Do you need any CBSs\' allocated?' && itemAnswer == 'Yes') {
emailaddresses += ",";
emailaddresses += StoreTeam;
}
if (itemQuestion == 'Do you need any COWs\' allocated?' && itemAnswer == 'Yes') {
emailaddresses += ",";
emailaddresses += StoreTeam;
}
if (itemQuestion == 'Do you need any Price Verifiers\' allocated?' && itemAnswer == 'Yes') {
emailaddresses += ",";
emailaddresses += StoreTeam;
}
if (itemQuestion == 'Do you need any Store Workstations\' allocated?' && itemAnswer == 'Yes') {
emailaddresses += ",";
emailaddresses += StoreTeam;
}
//END STORE TEAM TASKS
//Date Validation Logic
if (itemQuestion == 'When do you need the resource(s)?') {
var date1q1 = itemQuestion;
var startdate1 = itemAnswer;
}
if (itemQuestion == 'When will you release the resource(s)?') {
var date1q2 = itemQuestion;
var enddate1 = itemAnswer;
if (enddate1 < startdate1) {
emailaddresses = formResponse.getRespondentEmail();
emailSubject = '**INVALID REQUEST**Your end date is before your start date';
emailBody = 'You have entered invalid request data. You will need to submit a new request with accurate dates\nPlease click '+editURL+' to edit your start and end dates, then re-submit the form\n\n';
emailBody += date1q1+"\n";
emailBody += startdate1+"\n\n";
emailBody += date1q2+"\n";
emailBody += enddate1+"\n\n";
j = itemResponses.length
}
}
if (itemQuestion == 'Start date for Test lab store allocations') {
var date2q1 = itemQuestion;
var startdate2 = itemAnswer;
}
if (itemQuestion == 'End date for Test lab store allocations') {
var date2q2 = itemQuestion;
var enddate2 = itemAnswer;
if (enddate2 < startdate2) {
emailaddresses = formResponse.getRespondentEmail();
emailSubject = '**INVALID REQUEST**Your end date is before your start date';
emailBody = 'You have entered invalid request data. You will need to submit a new request with accurate dates\nPlease click '+editURL+' to edit your start and end dates, then re-submit the form\n\n';
emailBody += date2q1+"\n";
emailBody += startdate2+"\n\n";
emailBody += date2q2+"\n";
emailBody += enddate2+"\n\n";
j = itemResponses.length
}
}
if (itemQuestion == 'Start date for QA lab store allocations') {
var date3q1 = itemQuestion;
var startdate3 = itemAnswer;
}
if (itemQuestion == 'End date for QA lab store allocations') {
var date3q2 = itemQuestion;
var enddate3 = itemAnswer;
if (enddate3 < startdate3) {
emailaddresses = formResponse.getRespondentEmail();
emailSubject = '**INVALID REQUEST**Your end date is before your start date';
emailBody = 'You have entered invalid request data. You will need to submit a new request with accurate dates\nPlease click '+editURL+' to edit your start and end dates, then re-submit the form\n\n';
emailBody += date3q1+"\n";
emailBody += startdate3+"\n\n";
emailBody += date3q2+"\n";
emailBody += enddate3+"\n\n";
j = itemResponses.length
}
}
if (itemQuestion == 'Start date for Pre-Prod lab store allocations') {
var date4q1 = itemQuestion;
var startdate4 = itemAnswer;
}
if (itemQuestion == 'End date for Pre-Prod lab store allocations') {
var date4q2 = itemQuestion;
var enddate4 = itemAnswer;
if (enddate4 < startdate4) {
emailaddresses = formResponse.getRespondentEmail();
emailSubject = '**INVALID REQUEST**Your end date is before your start date';
emailBody = 'You have entered invalid request data. You will need to submit a new request with accurate dates\nPlease click '+editURL+' to edit your start and end dates, then re-submit the form\n\n';
emailBody += date4q1+"\n";
emailBody += startdate4+"\n\n";
emailBody += date4q2+"\n";
emailBody += enddate4+"\n\n";
j = itemResponses.length
}
}
}
// MailApp.sendEmail(emailaddresses, "New Request has been submitted for "+formResponse.getRespondentEmail(), emailBody);
MailApp.sendEmail(emailaddresses, emailSubject, emailBody, {replyTo:emailReplyTo});
var emailQuotaRemaining = MailApp.getRemainingDailyQuota()//;
Logger.log("Remaining email quota: " + emailQuotaRemaining);
}