cancel
Showing results for 
Search instead for 
Did you mean: 

How to get rid of JPFDocument.xml attachment?

0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Thanks for all your help guys.

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

Answers (2)

Answers (2)

0 Kudos

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

former_member190293
Active Contributor
0 Kudos

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.