1

I used Google Forms to make a 20-question quiz and added a page to the response spreadsheet that automatically grades the quiz immediately after it's submitted. I have this script in place to automatically email me the graded quiz:

function sendEmails() {
    var emailAddress = "[email protected]";
    var file=DriveApp.getFileById('1ipTs_BEwXqurQUfcZ_QO1E110vw3Zv_06BQ7bLbdTkY');

    MailApp.sendEmail(emailAddress, 'Completed Test', 'Please Review the attached test.', {attachments: [file.getAs(MimeType.PDF)]});
}

I would like to rename the pdf file with the quiz takers name ('tim laird.pdf' instead of the current 'completed test.pdf'). The quiz takers first and last name are in cell A1 and B1 of the sheet being sent as the pdf.

Can anybody help with that?

1 Answer 1

2

Something like this will rename the file pulling from cells a1:b1

var file=DriveApp.getFileById('1ipTs_BEwXqurQUfcZ_QO1E110vw3Zv_06BQ7bLbdTkY');
      var range = SpreadsheetApp.getActive().getRange('A1:B1');
      var first = range.getCell(1, 1);
      var last = range.getCell(1,2);
      var name = first.getValue() + ' ' + last.getValue();

      file.setName(name); 
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.