Jira Code: AHD-18
The script saves email attachment in the NS file cabinet. It fetch the attachment from the email and save in the particular directory
function process(email) {
try {
// log all information in email
var fromAddress = email.getFrom();
var recipientemail = email.getTo();
var attachments = email.getAttachments();
log("fromadd", fromAddress);
for (var indexAtt in attachments) {
// log('att', attachments[indexAtt]);
try {
log("indexAtt", attachments[indexAtt]);
var blob = attachments[indexAtt];
var blobnew = blob.getValue();
log("blobnew", blobnew);
var newFile = nlapiCreateFile('emialattachmnt.jpg', 'JPGIMAGE', blobnew);
newFile.setFolder(-4);
newFile.setEncoding('UTF-8');
nlapiSubmitFile(newFile);
log("newFile", newFile.getId());
} catch (e) {
log("e", e);
}
}
if (fromAddress != 'backdoor.e-4.r3@4973726.com' && recipientemail != 'backdoor.e-4.r3@4973726.com') {
log('from', fromAddress);
var a = {};
a.subject = email.getSubject();
log('subject', a.subject);
a.body = email.getHtmlBody();
log('html_body', a.body);
function test(params) {
log('params params', params);
var final = "POST"
return final;
}
nlapiRequestURL('https://forms.na3.netsuite.com/app/site/hosting/scriptlet.nl?script=290&deploy=1&compid=4301600&h=729f22e41c988ec7d0c2', blob, 'POST', 'POST');
}
} catch (e) {
log('error in main', e)
}
}
function log(label, text) {
nlapiLogExecution('DEBUG', label, text);
}