Sorry if this is not allowed but I have I believe something that may be similar.
I already have a script working well and doing various things but I just want to add 1 more attachment from the same drive to the email.
Everything can remain the same I am just wanting to add one additional pdf.
I have tried the above and various other suggestions but I am doing something wrong.
Below is my current script.
const SHEETID = '1rx1lCYKdhi8dhivoYpUO6EIHb2TWTpiMVduK7M-L2A4';
const DOCID = '1sRZqPCkuATT9tQDZlJDp-DicP6saBpZoAXVvKWXT_XM';
const FOLDERID = '1wsyrUM29A1LIiKCjsJE7olKb0ycG2_M5';
function PitchFees2026() {
const sheet = SpreadsheetApp.openById(SHEETID).getSheetByName('2026 Fees');
const temp = DriveApp.getFileById(DOCID);
const folder = DriveApp.getFolderById(FOLDERID);
const data = sheet.getDataRange().getValues();
const rows = data.slice(1);
rows.forEach((row,index)=>{
const file = temp.makeCopy(folder);
const doc = DocumentApp.openById(file.getId());
const body = doc.getBody();
data[0].forEach((heading,i)=>{
const header1 = heading.toUpperCase();
body.replaceText('{NAME}',row[1]);
body.replaceText('{PITCH}',row[0]);
body.replaceText('{AMOUNT}',row[3]);
body.replaceText('{FIRST}',row[4]);
body.replaceText('{SECOND}',row[5]);
body.replaceText('{REF}',row[10]);
body.replaceText('{BNAME}',row[7]);
body.replaceText('{CODE}',row[8]);
body.replaceText('{NUMBER}',row[9]);
body.replaceText('{TERMS}',row[6]);
})
doc.setName(row[10]);
const blob = doc.getAs(MimeType.PDF);
doc.saveAndClose();
const pdf = folder.createFile(blob).setName(row[10]+'.pdf');
const email = row[2];
const subject = row[10];
const messageBody = "This message (including any attachments) is intended only for the person or entity to which it is addressed and may contain confidential and/or privileged material. Any review, retransmission, dissemination, or other use of, or taking of any action in reliance upon, this information by persons or entities other than the intended recipient is prohibited. \n \nIf you received this in error, please delete the material from your computer and contact the sender. \n\nPlease consider the environment before printing this e-mail.";
MailApp.sendEmail({
to:email,
subject:subject,
body:messageBody,
attachments: [blob.getAs(MimeType.PDF)]
});
Logger.log(row);
file.setTrashed(true);
})
}
What I am wanting to attach is
var file = DriveApp.getFileById("1vGvLVP2RV1krxnj8Mt6hMiFHVBoIdbFG");
attachments.push(file.getAs(MimeType.PDF));
So I was trying to change to bottom of my main script to...
var attachments = []
var file = DriveApp.getFileById("1vGvLVP2RV1krxnj8Mt6hMiFHVBoIdbFG");
attachments.push(file.getAs(MimeType.PDF));
MailApp.sendEmail({
to:email,
subject:subject,
body:messageBody,
attachments: [blob.getAs(MimeType.PDF)]
});
Logger.log(row);
file.setTrashed(true);
})
}
Please may some assist me. I have been on this for days so probably not seeing something obvious now. Thank you so much in advance. :-)