I have just started learning can anyone please exp...
# general
d
I have just started learning can anyone please explain me how to use nlapiSendEmail to send scripts? and how to associate mails with record? please!
k
var email = { author: from_user, //The internal ID of the user the message will be from recipient: recipient, //A valid email address subject: "Some Subject", //Subject of the email. You can hard code this, assign a variable, or use with email merger and a template. body: "Body of my message in HTML", //Body in HTML. You can hard code this, assign a variable, or use with email merger and a template. cc: [], //An array of email addresses or an empty array bcc: [], //An array of email addresses or an empty array records: { transaction: rec.getId() } //Rec is an nlobjRecord. Pass in this object to attach the message to the record. }; try { nlapiSendEmail( email.author, //The internal ID of the user the message will be from email.recipient, //Valid email address of the person receiving the email email.subject, //Subject of your email. email.body, //Mesage body. email.cc, //An array of email addresses or an empty array email.bcc, //An array of email addresses or an empty array email.records //An object that lists the reocords to attach the message to. ); } catch(ex) { nlapiLogExecution("ERROR", "Could not send email for record " + rec.getFieldValue('tranid'), JSON.stringify(ex)); }
To attach to a record, you just pass in an object that has the record type and id. See above. Extracted this from some working code.
d
Thank you