嗨,我正在使用附加到Google Apps脚本的自定义表单来处理表单
因此该表单调用了processForm函数,该函数正在调用formatMailBody,该函数正在构建一个曾经是邮件正文的字符串
function processForm(e) {
var lock = LockService.getPublicLock();
lock.waitLock(30000);
try {
var requestID = record_data(e); // this function doesn't matter here
var mailData = e;
MailApp.sendEmail({
to: TO_ADDRESS, //Recipients emails
subject: 'blabla'
htmlBody: formatMailBody(requestID, mailData) // THE PROBLEM lie in this function
})
// return json success results
return ContentService
.createTextOutput(JSON.stringify({'result':'success', 'sampleMaterialReference':e['sampleMaterialReference'] }))
.setMimeType(ContentService.MimeType.JSON);
} catch(error) { // if error return this
Logger.log(error);
return ContentService
.createTextOutput(JSON.stringify({'result':'error', 'error': e}))
.setMimeType(ContentService.MimeType.JSON);
} finally { //release lock
lock.releaseLock();
}
}
function formatMailBody(id, obj) {
var result = 'construct the body of the email'
result+='<td bgcolor=\''+rowColor+'\'>'+obj["sampleType"]+'</td>'
Logger.log(obj);
Logger.log('<td bgcolor=\''+rowColor+'\'>'+obj["sampleType"]+'</td>');
return result;
}
所以这里的问题在于机体邮件的数组,应该是样本类型:test,而不是样本类型:t,有解决方案吗?