![](/img/trans.png)
[英]How to have Google Forms send automated email with new responses
[英]How to send confirmation email that includes massaged Google Forms data?
我創建了一個Google表單,通過在自動確認電子郵件中處理並與估算一起返回的表單提供信息,使受訪者能夠計算成本估算。
表單數據收集在表單響應電子表格中,並通過function = Query('表單響應1'!A:K)立即復制到第二個工作表。 公式應用於第二張表中的數據,以產生美元估算。
我在我在這里找到的Google表格中使用了一個腳本來生成確認電子郵件: http : //www.labnol.org/internet/auto-confirmation-emails/28386/#comment-1852825342
我遇到的問題是如何在確認電子郵件中找出如何顯示成本估算,該電子郵件將發送到受訪者表單。 如果我將它從第二個工作表中拉到“表單響應”表單中的最后一列,則在寫入每個新響應時它會碰到下一行,因為每個都會在工作表中插入一個新行。
另一方面,我無法弄清楚如何使用第二張而不是第一張中的字段填充確認電子郵件。
有什么解決方案嗎?
我認為您必須在其他網頁上創建Google應用腳本。 如果您的Google表單發送郵件,則必須在郵件中為具有ID(Google SP中的ID)的用戶添加鏈接。
在此步驟中,用戶具有“確認”狀態。
此鏈接必須是Google應用腳本才能更改此用戶的狀態。
您可以按照此解決方案並在之后添加更多功能。
Jean-Pierre Vermulst在Google Docs論壇上提供了很好的解決方案,其中包含兩行代碼,可以在自動配置電子郵件中顯示總計:
function SendConfirmationMail(e){
try {
var ss, cc, sendername, subject, columns;
var message, value, textbody, sender;
// This is your email address and you will be in the CC
cc = Session.getActiveUser().getEmail();
// This will show up as the sender's name
sendername = "[school name]";
// Optional but change the following variable
// to have a custom subject for Google Docs emails
subject = "Tuition & Fees Estimate";
// This is the body of the auto-reply
message = "Following is an estimate of your family's tuition and fees for the upcoming school year ...;
ss = SpreadsheetApp.getActiveSheet();
columns = ss.getRange(1, 1, 1, ss.getLastColumn()).getValues()[0];
// This is the submitter's email address
sender = e.namedValues["Email Address"].toString();
var sheet = SpreadsheetApp.getActive().getSheetByName('Form Responses 1');
// Only include form values that are not blank
for ( var keys in columns ) {
var key = columns[keys];
if ( e.namedValues[key] ) {
message += key + ' :: '+ e.namedValues[key] + "<br />";
}
}
message += 'TOTAL :: $' + sheet.getRange(sheet.getLastRow(), 12).getValue();
textbody = message.replace("<br>", "\n");
Logger.log(message);
GmailApp.sendEmail(sender, subject, textbody,
{cc: cc, name: sendername, htmlBody: message});
} catch (e) {
Logger.log(e.toString());
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.