我已经使用以下代码设置了一个触发器,以在员工每次提交请求时发送一封电子邮件。这基本上是发送一个小册子(PNG 格式并存储在 Google Drive 中)。不知何故,代码不起作用。几乎一整天都在网上搜寻答案,但没有任何帮助。我尝试了 DriveApp.getFileByID 方法并且它有效,但这只是一个文件。附件取决于员工在 Google 表单上选择的产品,并且是动态的。
任何帮助深表感谢。谢谢!
function SendBrochure(e) {
try {
var email = e.values[1];
var subject = "ABC Co - Information you requested";
var msgcc = "test@gmail.com";
var aliases = GmailApp.getAliases();
var cxnm = e.values[2] + " " + e.values[3] + " " + e.values[4];
var msgl1 = "Greetings from ABC Co, " + cxnm + ".";
var emailText = "<b>Greetings from ABC Co, " + cxnm + ". </b> <p>With reference to your conversation
with us and your request for information, please find attached herein the same.</p> <p> Should you
require further assistance, please contact the undersigned, or refer to the brochure for pertinent
site contact details.</p> <p>We appreciate your interest and look forward to your visit soon.</p>
<p> Thanks and regards, <br><b>ABC Co</b><br>Tel: +1 202 555 1212<br>Web:
www.abc.com </p>";
var brochurename = e.values[5]; //gets file name from form (already filled in - for e.g f_1.png)
var brochure1 = DriveApp.getFilesByName(brochurename);
GmailApp.sendEmail(email, subject, msgl1, {
name: 'ABC Co',
attachments: [brochure1.next()],
htmlBody: emailText,
from: aliases[1]
});
GmailApp.sendEmail(msgcc, "Email sent!", "Your email request to " + email + " has been completed successfully at " + e.values[0], {
'from': aliases[1]
});
} catch (e) {
Logger.log(e.toString());
}
}