Saturday, September 15, 2018

Send Email to a Group of People using nlapiSendEmail


The customer can follow steps below to send out an email to a number of people. For this sample, assume that user wants to send email to their company's managers.


1. Use a search. For example there is a checkbox in their employee record which will tell that the employee is a manager.
2. Use nlapiSearchRecord and obtain all the emails of the managers
3. Create an array of emails and pass it onto the CC or BCC parameter of nlapiSendEmail

Sample Code Snippet:

function sendEmail(type) {
 var filters = new Array();
 filters[0] = new nlobjSearchFilter('custbody_ismanager', null, 'is', 'T');

 var columns = new Array();
 columns[0] = new nlobjSearchColumn('email');

 results = nlapiSearchRecord('employee', null, filters, columns);

 var emailArray = new Array();

 for (var i in results) {
  emailArray[i] = results[i].getValue('email');
 }

 nlapiSendEmail(-5, 1, 'Test', 'Test', emailArray, null, null, null);
}

 

DISCLAIMER: The sample code described herein is provided on an "as is" basis, without warranty of any kind, to the fullest extent permitted by law. NetSuite Inc. does not warrant or guarantee the individual success developers may have in implementing the sample code on their development platforms or in using their own Web server configurations. NetSuite Inc. does not warrant, guarantee or make any representations regarding the use, results of use, accuracy, timeliness or completeness of any data or information relating to the sample code. NetSuite Inc. disclaims all warranties, express or implied, and in particular, disclaims all warranties of merchantability, fitness for a particular purpose, and warranties related to the code, or any service or software related thereto. NetSuite Inc. shall not be liable for any direct, indirect or consequential damages or costs of any type arising out of any action taken by you or others related to the sample code.

No comments:

Post a Comment