I am having a lot of trouble with actually getting the file to attach to the email I'm sending, I have been using the code below and the email is sending but the file is not being included.
function myCoding() {
var array = SpreadsheetApp.getActiveSheet().getDataRange().getValues();
for(var i=1;i<array.length;i++){
var loopEmail = array[i][0];
var loopName = array[i][1];
var loopNN = array[i][2];
var loopSize = array[i][3];
var loopColour = array[i][4];
text = "Hey " + loopName;
text1 = "\n Your full name for the hoodie is: "+ loopName + ", your nickname for your hoodie is " + loopNN + " and your size is " +loopSize + ". You have chosen the colour "+loopColour + ".";
text3 = "\n"
var file = DriveApp.getFilesByName('DrinksShopPartnerProgram.pdf');
if (file.hasNext()) {
GmailApp.sendEmail(loopEmail, "DGS", text + text3 + text1 + text3, file);
attachments: [file.next().getAs(MimeType.PDF, )]
}
}
}
attachments
is after the;
, so it's outside the GmailApp method. – Jescanellas