我正在制作一个工具来制作新的Google文档并通过电子邮件将其发送给我的某个主题的老师,但是我的变量“主题”需要包含文档链接,这意味着我需要先创建文档,然后声明可变主题,但是,为了知道如何命名文档,我需要访问存储在可变主题中的信息。有什么建议?我的JavaScript在下面。
function doGet() {
return HtmlService.createHtmlOutputFromFile('Index.html');
}
function customDoc(subject) {
var formattedDate = Utilities.formatDate(new Date(), Session.getScriptTimeZone(), 'M/d/yyyy');
var subjects = {
'math': {
email: 'teacher@example.com',
preSubject: 'math for '
},
'la': {
email: 'teacher@example.com',
preSubject: 'la for '
},
'science': {
email: 'teacher@example.com',
preSubject: 'science for '
},
'is': {
email: 'teacher@example.com',
preSubject: 'I&S for '
},
'spanish': {
email: 'teacher@example.com',
preSubject: 'Español para '
message: 'Español para ' + formattedDate + 'This is supposed to be where the link to the google doc is, so this is where the paradox comes in. '
}
};
console.log('Today: ' + formattedDate);
console.log('Subject: ' + subject);
console.log(subjects[subject]);
GmailApp.sendEmail(subjects.email, subjects.preSubject, subjects.message)
}