process(email)
Function Declaration |
|
Type |
Interface function |
Description |
Interface function that contains the implementation of the business logic of the Email Capture plug-in. NetSuite calls this function when it receives an email message sent to the email address associated with the plug-in implementation. See Email Capture Process Flow. Use the methods available to the Email object to retrieve the properties of the email message, such as sender and recipient fields as Address objects, subject and body fields, sent date, and attachments as Attachment objects. |
Returns |
void |
Parameters |
Example
function process(email) {
...
// log all information in email
var fromAddress = email.getFrom();
logAddress('from', fromAddress);
var to = email.getTo();
for (var indexTo in to)
{
logAddress('to', to[indexTo]);
}
var cc = email.getCc();
for (var indexCc in cc)
{
logAddress('cc', cc[indexCc]);
}
logAddress('replyTo', email.getReplyTo());
nlapiLogExecution('DEBUG', 'sent', email.getSentDate());
nlapiLogExecution('DEBUG', 'subject', email.getSubject());
nlapiLogExecution('DEBUG', 'text body', email.getTextBody());
nlapiLogExecution('DEBUG','html body', email.getHtmlBody());
var attachments = email.getAttachments();
for (var indexAtt in attachments)
{
nlapiLogExecution('DEBUG', 'attachments', attachments[indexAtt]);
}
function logAddress(label, address)
{
if (address)
{
nlapiLogExecution('DEBUG', 'Email - ' + label + ': ' + address.getName() + ', ' + address.getEmail());
}
}
...
...
}