on 10-27-2015 4:19 PM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
80 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
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.