Add email manually to the communications tab of a transaction
The messages sublist is not editable or dynamic, so you do not add items to it directly. Instead you add to it by sending an email via the N/email.send() API and providing the relevant transaction as a Related Record in the options.
Example :
email.send({
author: "123",
recipients: ["test@test.com", "another-test@test.com"],
subject: "This is an email",
body: "Probably the best email ever",
relatedRecords: {
transactionId: recordId // <-- relevant transaction ID here
}
});