Sidebar

How to attach pdf file into RESTful Webservice for Secure emailing.

0 votes
518 views
asked Sep 5, 2017 by niran-k-8380 (120 points)

1 Answer

0 votes

You can create a custom mapping that uses sendinc.com for the WS call. Read up your pdf and then attach it to a WS call that will handle the attachment for you.

 

var emailTo = 'xyz@email.com,123@email.com';
var fileBytes = qie.readFile('filepath');
var parameterMap = qie.newParameterMap();
parameterMap.put('http.header.encoding', 'ISO-8859-1');
var urlTemplate = qie.evaluateTemplate('https://rest.sendinc.com/message.xml');
var content = ('Content-Type:multipart/form-data; boundary=AaB03x\n'+
   '\n'+
   '--AaB03x\n'+
   'Content-Disposition:form-data; name=\'email\'\n'+
   '\n'+
   'abc@example.com\n'+
   '--AaB03x\n'+
   'Content-Disposition:form-data; name=\'recipients\'\n'+
   '\n'+
   emailTo + '\n'+
   '--AaB03x\n'+
   'Content-Disposition:form-data; name=\'subject\'\n'+
   '\n'+
   'Test Message\n'+
   '--AaB03x\n'+
   'Content-Disposition:form-data; name=\'message\'\n'+
   '\n'+
   'This is a Test Message \n'+
   '--AaB03x\n'+
   'Content-Disposition:inline; name=\'file\'; filename=\'1.pdf\'\n'+
   'Content-Type:application/pdf\n\n'+
   new java.lang.String(fileBytes, 'ISO-8859-1')+ '\n' +
   '--AaB03x--\n');
var value = qie.callRESTWebService('asendinc', urlTemplate,'POST',content,'multipart/form-data;boundary=AaB03x',parameterMap);

answered Oct 2, 2017 by michael-h-5027 (14,350 points)
...