How to save attached file to netsuite and sent the file as email attachment

To save user uploaded attachment to netsuite backend , First of all use “nlapiCreateFile” format. Using “nlapiCreateFile” command the same file is created in the netsuite ssp folder. And that particular file can be move to another folder by using “setFolder” command and the file id can be obtained by “nlapiSubmitFile” command . To send the file as email attachment, load the file by “nlapiLoadFile” command and then use “nlapiSendEmail” command.

Below shows an example for the same.

Here 23710 is the folder id.

 var newResaleFile= nlapiCreateFile(filename, fileType, attachment);
          newResaleFile.setFolder(23710);
      	  var newResaleFileId = nlapiSubmitFile(newResaleFile);
          nlapiLogExecution('DEBUG', 'newResaleFileId', newResaleFileId);
          var newattachment= nlapiLoadFile(newResaleFileId)
    
          nlapiSendEmail(sender, recipient, subject, dataToSend, null, null, null, newattachment, false, false, email);

Leave a comment

Your email address will not be published. Required fields are marked *