on 02-14-2017 4:45 AM
Hi,
I am using a java mapping to create a mail with two attachments.
I am able to get two attachments in the end, but there is a third attachment JPFDocument.xml in my mail which is blank. Can anyone please help me to get rid of this attachment.
Here is the sample code.
Map mapParameters = (Map) in.getInputHeader().getAll(); mapParameters.put(DynamicConfigurationKey.create("http://sap.com/xi/XI/Dynamic", StreamTransformationConstants.DYNAMIC_CONFIGURATION), ""); DynamicConfiguration conf = (DynamicConfiguration) mapParameters.get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);
// Recipient Address
DynamicConfigurationKey recipients = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "THeaderTO"); conf.put(recipients, "abc@test.com");
InputStream ins = in.getInputPayload().getInputStream();
OutputStream outs = out.getOutputPayload().getOutputStream();
ins.close();
String ResponseXML = "This is a test";
byte[] ResponseByte = ResponseXML.getBytes();
String ResponseFilename = "File1_out" + ".xml";
OutputAttachments outputAttachments = out.getOutputAttachments();
Attachment ResponseAttch = outputAttachments.create(ResponseFilename, ResponseByte);
outputAttachments.setAttachment(ResponseAttch);
String ResponseXML = "This is a test1";
byte[] ResponseByte = ResponseXML.getBytes();
String ResponseFilename = "File2_out" + ".xml";
OutputAttachments outputAttachments = out.getOutputAttachments();
Attachment ResponseAttch = outputAttachments.create(ResponseFilename, ResponseByte);
outputAttachments.setAttachment(ResponseAttch);
Regards,
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your reply Evgeniy,
Both if the files which I am attaching are xml files. I tried to remove all the content and tried to add the Xheadername1 and set the content type, but the result is still the same.
DynamicConfigurationKey mailHeader = DynamicConfigurationKey.create("http://sap.com/xi/XI/System/Mail", "XHeaderName1"); mailHeaderValue = "attachment; filename=\"Testfile.xml\"";
conf.put(mailHeader, mailHeaderValue);
CompositeContentType = "text/xml" + ";charset=\"" + "UTF-8" + "\";filename=\"Testfile.xml\""; out.getOutputHeader().setContentType(CompositeContentType);
String MsgPrefix = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><DummyMessageMT><Dummy><Dummyfield>";
String MsgSuffix = "</Dummyfield></Dummy></DummyMessageMT>";
ResponseByte = (MsgPrefix + "This is test"+ MsgSuffix).getBytes();
outs.write(ResponseByte);
Please let me know if I am missing anything.
Regards,
Prashant
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Prashant!
It looks like you don't compose any xml/text/html document as output payload. I guess that mail adapter creates third attachment for your empty main payload and as far as it's not in xml format it uses JPFDocument instead of MainDocument as attachment name. But it's just a guess.
Regards, Evgeniy.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
95 | |
13 | |
13 | |
11 | |
11 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.