Skip to Content
0

How to get rid of JPFDocument.xml attachment?

Feb 14, 2017 at 04:45 AM

71

avatar image

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

3 Answers

Best Answer
Prashant Bhavsar Feb 23, 2017 at 12:31 AM
0

Thanks for all your help guys.

I managed to fix this by adding MessageTransformBean and set the contentDisposition to inline.


Share
10 |10000 characters needed characters left characters exceeded
Evgeniy Kolmakov Feb 14, 2017 at 08:28 PM
0

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.

Share
10 |10000 characters needed characters left characters exceeded
Prashant Bhavsar Feb 21, 2017 at 04:23 AM
0

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

Share
10 |10000 characters needed characters left characters exceeded