Skip to Content
Nov 02, 2018 at 03:07 PM

File (nfs) to Mail - additional file attached as .xml (original is .zip)


Hi Gurus,

I am developing a file to mail scenario, where I need to send a .zip file to some mail recipients and have some text in the body.

For this purpose, I am using sender File System adapter (NFS) because I am reading the body text from a .txt located in the same path as the file that needs to be attached so I need to use the Additional File(s) parameter for this purpose.

I am able to read the .txt file and have that string in the body of the mail sent and also read the .zip file but it is being attached as .xml and not as .zip

Here are some details in my channels:

Sender file adapter

  • Source tab is File System (NFS) and Additional File(s) option is enabled
  • Processing tab has processing mode as test and File Type as Binary
  • Advanced tab has enabled the ASMA feature with File Name and File Type checkboxes

Receiver mail adapter

  • General tab is NOT using mail package; I completed the textboxes for "from", "to" and "subject" and content encoding is base64. Keep attachments is enabled.
  • In module tab I am using MessageTransformBean with ContentDisposition as inline and ContentType as text/plain;charset="UTF-8"

The way I developed this interface is with no ESR objects (service interfaces are defined as dummy).

I algo tried using Java Mapping for this purpose (only difference is that in the general tab of the recever mail adapter I defined the "To" and "Subject" as Dummy because I am adding that in my MM code). The code used is next one:

public void transform(TransformationInput input, TransformationOutput output) throws StreamTransformationException {
  InputStream inStream = input.getInputPayload().getInputStream();
  OutputStream outStream = output.getOutputPayload().getOutputStream();
  try {
   // Transfer main payload content from input to output
   byte[] content = getInputStreamBytes(inStream);
   // Update dynamic configuration attributes
   DynamicConfiguration dynConfig = input.getDynamicConfiguration();
   // (1) Email To
   DynamicConfigurationKey emailToKey = DynamicConfigurationKey.create("", "THeaderTO");
   dynConfig.put(emailToKey, "");
   // (2) Email Subject
   DynamicConfigurationKey subjectKey = DynamicConfigurationKey.create("", "THeaderSUBJECT");
   dynConfig.put(subjectKey, "Subject from Java Mapping");
  } catch (Exception e) {
   throw new StreamTransformationException("Exception: " + e.getMessage(), e);
private byte[] getInputStreamBytes(InputStream inStream) throws IOException {
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  byte[] buffer = new byte[8192];
  int read = 0;
  while ((read =, 0, buffer.length)) != -1) {
   baos.write(buffer, 0, read);
  return baos.toByteArray();

Which also works fine but the result is the same one (attached zip appears as .xml)

I assume this might be something weird but I am not able to find the solution.

Is anyone able to let me know how can I attach the .zip file with the right extension?

Thanks in advanced!