我创建了用户事件脚本来发送电子邮件。我想从公司信息电子邮件地址发送电子邮件,但收到错误消息,
{"type":"error.SuiteScriptError","name":"SSS_AUTHOR_MUST_BE_EMPLOYEE","message":"作者内部 ID 或电子邮件必须与员工匹配。","id":"","stack":[ "doSendEmail(N/email)","afterSubmit(/SuiteScripts/emailsend.js:20)"],"原因":{"type":"内部错误","code":"SSS_AUTHOR_MUST_BE_EMPLOYEE","详细信息": "作者内部 ID 或电子邮件必须与员工匹配。","userEvent":"aftersubmit","stackTrace":["doSendEmail(N/email)","afterSubmit(/SuiteScripts/emailsend.js:20)"] ,"notifyOff":false},"notifyOff":false,"userFacing":false}
下面是我的代码:
/**
* @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
};
});
有什么办法可以解决这个问题吗?
您无法使用任意发件人电子邮件从 NetSuite 发送电子邮件。
author
的 email.send
参数必须是活动员工记录的数字内部 ID。
您的客户应创建专用于此目的的员工记录并为其提供所需的电子邮件地址,然后您的脚本可以使用新记录的内部 ID 作为
author
。
许多公司都会设立一个通用的“不回复”员工。员工不需要登录访问权限,因此不需要使用许可证。