on 2018 Nov 02 3:07 PM
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
Receiver mail adapter
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);
outStream.write(content);
// Update dynamic configuration attributes
DynamicConfiguration dynConfig = input.getDynamicConfiguration();
// (1) Email To
DynamicConfigurationKey emailToKey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "THeaderTO");
dynConfig.put(emailToKey, "blabla@blabla.com");
// (2) Email Subject
DynamicConfigurationKey subjectKey = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "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 = inStream.read(buffer, 0, buffer.length)) != -1) {
baos.write(buffer, 0, read);
}
baos.flush();
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!
Hi Pavan,
Thanks for the quick reply.
I already tried using PayloadZipbean module and didn't work but I was able to solve it.
The issue was in the additional file options there is a textbox called "file list" so I put there the extension (.zip) after the filename and my attachment now has the naming convention I was looking for.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Have you tried using PayloadZipbean module with parameter name as zip.mode and value as zip/ zip one in mail receiver cc.
If my understanding correcting xml file will be actual main payload and name attaching as Maindocument.xml
Regards
Pavan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
62 | |
9 | |
8 | |
6 | |
6 | |
6 | |
6 | |
6 | |
5 | |
5 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.