Can I attach invoice to email and send via a trigger from the email icon

I have created an invoce sheet and want to be able to emailthe invoice directly to the customer via the email icon.

can this be scripted to act as a trigger in the invoice sheet?

Ninox Profile

Attach script to a "Email Invoice" button:

let myinvoice := importFile(this, printAndSaveRecord(this, "Name of invoice layout"), "mypdf.pdf");
from: text(userEmail()),
to: text('IssueEmailto'),
subject: "Hello World!",
text: "Some text",
html: "<h1>Some Text</h1><i>With Markup</i>",
attachments :myinvoice