I have created a SuiteScript UserEventScript, which is called by an Advanced PDF/HTML Template, which gets triggered when printing to PDF from an invoice, but doesn't seem to get triggered when sending an email through Invoice > Actions > Email (which includes that same PDF template).
The reason I think the UserEventScript doesn't get triggered when emailing is that script's execution log doesn't contain any logging when emailing, but does contain logging when printing to PDF.
The top of the script:
Printing invoice to PDF:
Emailing
I ended up changing my SuiteScript UserEventScript to write the data to a field added to the Invoice, rather than adding a field during the UserEventScript. That way the template could always see this field since it was always present, even if the UserEventScript wasn't running during the email context.