I am trying to specify the mail file attachment name in my Apps Script code. The email sends correctly, however, the attachment is only named a generic name 'mime-attachment.pdf' or 'mail-attachment.pdf' depending on the mail client. I'm currently using the following code:
var message = {
to: recipient,
subject: subject,
body: body,
attachments: SpreadsheetApp.getActiveSpreadsheet().getAs(MimeType.PDF).setName("Sales Report")
}
MailApp.sendEmail(message);
How can I specify the name of the attachment?