on 09-19-2014 4:23 AM
Hi everyone,
I have a new requirement but I´m with doubts, how to send an e-mail with two attachements (XML and PDF) and body text using -
MIME: multipart/mixed;boundary
I already have code to send XML + body text as you can see below:
Element contentType = docout.createElement("Content_Type");
root.appendChild(contentType);
Text contentTypeText = docout.createTextNode("multipart/mixed;boundary=--AaZz");
absTraceLog.addDebugMessage("Content_Type e-mail --- "+contentTypeText.toString());
contentType.appendChild(contentTypeText)
String text = "----AaZz\r\nContent-Type: text/plain; charset=UTF-8\r\n" +
"Content-Disposition: inline\r\n\r\n" + nfeText +
"\r\n----AaZz\r\nContent-Disposition: attachment; filename="+ prefixo +" "+ chaveNFe +".xml" +"\r\n\r\n" + xmlString + "\r\n";
Element content = docout.createElement("Content");
root.appendChild(content);
contentText = docout.createTextNode(text);
Content.appendChild(contentText);
The code above work good, but I can´t duplicate any field from XiMail 3.0 - because it´s 0:1.
So how to do that ?
Thanks.
Regards,
BR.
Viana.
Hi Ricardo
Just my two cents.
If you have multiple attachments, have you considered NOT using the Mail Package, and selecting "Keep Attachments" in the receiver channel?
You create the two attachments during the mapping part, and forward them at the adapter.
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.
Hi Ricardo
The reason for my suggestion is because usage of Mail Package is deprecated - refer note 856599.
The body text can be taken from the MainDocument. You can refer to the below document, item 3.2.4 where it describes sending a mail with body and attachments. The MainDocument payload can be set as the body by setting the ContentDisposition to inline.
What you mean mapping part ? Use a MM ? Module Adapter ?
I meant Operation Mapping (using either a Java Mapping or Message Mapping with UDF) to set the attachments.
Rgds
Eng Swee
Eng,
That´s works good with mailPackage:
content= "--" + "--Zz" + CRLF
+ "Content-Type: text/html; charset=UTF-8" + CRLF
+ "Content-Disposition: inline" + CRLF + CRLF
+ textBodyMail + CRLF
+ "--" + "--Zz" + CRLF
+ "Content-Type: application/xml; name=" + attachmentName + CRLF
+ "Content-Disposition: attachment; filename=" + attachmentName + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF + CRLF
+ encoder.encode(inputString.getBytes("UTF-8")) + CRLF
+ "--" + "--Zz" + CRLF
+ "Content-Type: application/pdf; name=" + pdfName + CRLF
+ "Content-Disposition: attachment; filename=" + pdfName + CRLF
+ "Content-Transfer-Encoding: base64" + CRLF + CRLF
+ encoder.encodeBuffer(new BASE64Decoder().decodeBuffer(pdfAttachment));
Regards,
BR.
Ricardo Viana.
Hi Everyone,
I am trying to send email with body and XML attachment ( with .txt extension ).
I am using same way of preparing message as Ricardo's working solution mentioned above without using encoder part.
Email is going OK with body and attachment. But attachment data is getting line breaks after 2050 characters.
I want to try using "encoder.encode(inputString.getBytes("UTF-8")) "
Does anyone give me what class we should use to create that encoder object to send xml data with .txt extension ?
Any help is appreciated.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
6 | |
6 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.