cancel
Showing results for 
Search instead for 
Did you mean: 

Email receiver creates MainDocument.xml instead of mail body

ChRa
Explorer
0 Kudos

Hello,

im using a JAVA-Mapping with mail package to create a mail with content and attachment.

This is my Coding.


InputStream inputstream = input.getInputPayload().getInputStream();

OutputStream outputstream = output.getOutputPayload().getOutputStream();

String mailOutput = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"

        + "<ns:Mail xmlns:ns=\"http://sap.com/xi/XI/Mail/30\">\n"

        + " <Subject>" + subject + "</Subject>\n"

        + " <From>" + mailFromAdress + "</From>\n"

        + " <To>" + mailToAdress + "</To>\n"

        + " <Reply_To/>\n"

        + " <Content_Type>text/plain</Content_Type>\n"

        + " <Content>MailContent</Content>\n"

        + "</ns:Mail>";

outputstream.write(mailOutput.getBytes());

byte[] bAttachment = new byte[inputstream.available()];

inputstream.read(bAttachment);

Attachment newAttachment = output.getOutputAttachments().create(attachmentname, "application/xml", bAttachment);

output.getOutputAttachments().setAttachment(newAttachment);

this is the configuration of the mail receiver.

the output is always the same.

two XML-Documents

The first with the text "MailContent".

The second with the right output as attachment.

what do i have to do to convert the MainDocument a real text in the mail body?

My result should be one mail with one attachment and a text as body. Either plain or als html.

br

Accepted Solutions (0)

Answers (1)

Answers (1)

engswee
Active Contributor
0 Kudos

Hi Christian

First of all, the use of Mail Package is deprecated.

Refer to Stefan's blog below on how to create an email with attachments without Mail Package.

However, if you insist on using Mail Package, you need to set the ContentDisposition to "inline" so that the Main Document is set as the mail body. You can use MessageTransformBean to set it - refer section 3.2.4 in the following document

Here's another alternative using Mail Package where you manually construct the whole MIME stream for the body and attachments.

Rgds

Eng Swee