I have created user event script to send email. I want to send email from company enformation email address, but I am getting error as,
{"type":"error.SuiteScriptError","name":"SSS_AUTHOR_MUST_BE_EMPLOYEE","message":"The author internal id or email must match an employee.","id":"","stack":["doSendEmail(N/email)","afterSubmit(/SuiteScripts/emailsend.js:20)"],"cause":{"type":"internal error","code":"SSS_AUTHOR_MUST_BE_EMPLOYEE","details":"The author internal id or email must match an employee.","userEvent":"aftersubmit","stackTrace":["doSendEmail(N/email)","afterSubmit(/SuiteScripts/emailsend.js:20)"],"notifyOff":false},"notifyOff":false,"userFacing":false}
Below is my code:
/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
define(['N/email', 'N/log'], function(email, log) {
function afterSubmit(context) {
try {
// Get the current record
var newRecord = context.newRecord;
var emailAddress = '[email protected]'
var name = "oracle netsuite"
// Send email
email.send({
author: '[email protected]', // or any other internal id
recipients: emailAddress,
subject: 'Example Subject',
body: 'Dear ' + name + ',\n\nThis is an example email sent from SuiteScript.',
});
log.debug('Email Sent', 'An email has been sent to ' + emailAddress);
} catch (e) {
log.error('Error Sending Email', e);
}
}
return {
afterSubmit: afterSubmit
};
});
Is there any way to work this?
You cannot send email from NetSuite using an arbitrary sender email. The author
parameter of email.send
must be a numeric internal ID of an active Employee record.
Your client should create an Employee record dedicated to this purpose and give it the desired email address, then your script can use the internal ID of the new record as the author
.
Many companies make a generic "No Reply" Employee. The Employee does not need login access and so does not need to consume a license.