if (newRec_id) {
//create an email record under the mail merge
var emailRec = nlapiCreateRecord("message");
emailRec.setFieldValue("subject", emailSubject);
emailRec.setFieldValue("message", bodyMessage);
emailRec.setFieldValue("recordtype", 4144);
emailRec.setFieldValue("record", newRec_id);
emailRec.setFieldValue("author", 285164);
emailRec.setFieldValue("recipient", 285164);
nlapiLogExecution("DEBUG", "newRec_id - ", newRec_id);
nlapiLogExecution("DEBUG", "emailRec - ", emailRec);
var emailRec_id = nlapiSubmitRecord(emailRec);
nlapiLogExecution("DEBUG", "emailRec_id - ", emailRec_id);
// UNEXPECTED_ERROR -> null; ID: m7ua5cbl1qy5gaqpz08vr
}