简体   繁体   English

如何发送包含按摩Google表格数据的确认电子邮件?

[英]How to send confirmation email that includes massaged Google Forms data?

I've created a Google Form to enable respondents to calculate an estimate of costs by providing information through the form that is processed and returned with the estimate in an auto confirmation email message. 我创建了一个Google表单,通过在自动确认电子邮件中处理并与估算一起返回的表单提供信息,使受访者能够计算成本估算。

Form data is collected in the Form Responses spreadsheet and copied instantly to a second worksheet through function =Query('Form Responses 1'!A:K). 表单数据收集在表单响应电子表格中,并通过function = Query('表单响应1'!A:K)立即复制到第二个工作表。 Formulas are applied to the data in the second sheet to result in a dollar estimate. 公式应用于第二张表中的数据,以产生美元估算。

I'm using a script in my Google sheet that I found here in order to generate the confirmation email: http://www.labnol.org/internet/auto-confirmation-emails/28386/#comment-1852825342 我在我在这里找到的Google表格中使用了一个脚本来生成确认电子邮件: http//www.labnol.org/internet/auto-confirmation-emails/28386/#comment-1852825342

Where I'm stuck is in figuring out how to display the cost estimate in the confirmation email that goes to the form respondent. 我遇到的问题是如何在确认电子邮件中找出如何显示成本估算,该电子邮件将发送到受访者表单。 If I pull it from the second sheet into the last column in the Form Responses sheet, then it gets bumped to the next row when each new response is written, since each inserts a new row into the sheet. 如果我将它从第二个工作表中拉到“表单响应”表单中的最后一列,则在写入每个新响应时它会碰到下一行,因为每个都会在工作表中插入一个新行。

On the other hand, I can't figure out how to populate the confirmation email message with fields from the second sheet instead of the first. 另一方面,我无法弄清楚如何使用第二张而不是第一张中的字段填充确认电子邮件。

Any solutions for me? 有什么解决方案吗?

I think you must create a Google app script in an other webpage. 我认为您必须在其他网页上创建Google应用脚本。 If your google-form send mail, you must add link for the user with an id ( id in the Google SP ) in your mail. 如果您的Google表单发送邮件,则必须在邮件中为具有ID(Google SP中的ID)的用户添加链接。

In this step , the user has a status "in confirmation". 在此步骤中,用户具有“确认”状态。

This link must be a Google app script to change status for this user. 此链接必须是Google应用脚本才能更改此用户的状态。

you can follow this solution and add more features after. 您可以按照此解决方案并在之后添加更多功能。

Great solution from Jean-Pierre Vermulst over on Google Docs Forums, incorporating two lines of code that cause the display of the total in the auto-confiration email: Jean-Pierre Vermulst在Google Docs论坛上提供了很好的解决方案,其中包含两行代码,可以在自动配置电子邮件中显示总计:

function SendConfirmationMail(e) { 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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM