Hi Ram,
Enable "Read Attachments" option in interface/operation mapping.
Try with this java mapping code,
import java.io.*; import java.util.*; import com.sap.aii.mapping.api.AbstractTrace; import com.sap.aii.mapping.api.*; public class CreateAttachmentJM extends AbstractTransformation{ public void transform(TransformationInput in, TransformationOutput out) throws StreamTransformationException { try { DynamicConfiguration conf = (DynamicConfiguration) in.getDynamicConfiguration(); DynamicConfigurationKey KEY_FILENAME = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/File","FileName"); String fileName = conf.get(KEY_FILENAME); String contentType = contentType + ";charset = \"UTF-8\";"+ "name=\"" + fileName + "\""; int len = 0; byte[] buffer = new byte[1024]; ByteArrayOutputStream baos = new ByteArrayOutputStream(); InputStream is = (InputStream) in.getInputPayload().getInputStream(); while ((len = is.read(buffer)) > 0) { baos.write(buffer, 0, len); //out.getOutputPayload().getOutputStream().write(buffer, 0, len); } String yourMailBody = "Hello"; //Comments: you can have your content here and I believe this will reflect as mail body based on mail channel setting out.getOutputPayload().getOutputStream().write(yourMailBody.getBytes()); Attachment newopAttachmentForMail = out.getOutputAttachments().create(fileName, contentType, baos.toByteArray()); out.getOutputAttachments().setAttachment(newopAttachmentForMail); }catch(Exception e){ e.printStackTrace(); } } }
Best Regards,
Praveen Gujjeti