Hi All,
I have a script that has been working fine, emails are being sent and they are being attached to a corresponding custom record, however I've just started to have problems where by if I try to CC an array of addresses into the email the email sends correctly but will not attach to the record.
If there is no value in the array the script sends the email and attaches to the array as the CC section of nlapisendemail is set to null.
Can anyone see any glaring mistake I have made which would cause the email not to attach to the record??
var emailRecords = new Object(); emailRecords['recordtype'] = newRec.getRecordType(); emailRecords['record'] = newRec.getId(); //Set up array of email addresses var ccArray = new Array(); if (clientEmail != null) {ccArray.push(clientEmail);} if (ManagerEmail != null) {ccArray.push(ManagerEmail);} if (CaseAdvEmail != null) {ccArray.push(CaseAdvEmail);} if (Email1 != null) {ccArray.push(Email1);} if (Email2 != null) {ccArray.push(Email2);} //Extract First Array entry for main TO address var toAddress = ccArray.shift(); nlapiLogExecution('DEBUG', 'To Address', toAddress); if (toAddress != '') { //Send Email if (0 < ccArray.length) { nlapiSendEmail(90465, toAddress, emailSubject, emailBody, ccArray, null, emailRecords, null); nlapiSetFieldValue('custrecord_wpa_ass_cli_confirm_sent', 'T'); //Set Confirmation Sent Field nlapiSetFieldValue('custrecord_wpa_ass_cli_confirm_sent_on', today); //Set Confirmation Sent On Field } else { nlapiSendEmail(90465, toAddress, emailSubject, emailBody, null, null, emailRecords, null); //Set Sender to 90465 SYSTEM, SERVDEL defaulted to administration email } } }