Reputation:
I have an app that talks to someone else's server by sending emails with attachments.
I used Apache Commons Email to send the email with attachment like so:
MultiPartEmail email = new MultiPartEmail();
email.setHostName(sHostName);
email.addTo("[email protected]");
email.addFrom("[email protected]");
email.setSubject("the subject");
email.setMsg("the message");
byte[] documentFile = /* ... */;
String filename = "my file.pdf";
String description = "this is my file";
email.attach(new ByteArrayDataSource(myPDF, "application/pdf"), filename, description, EmailAttachment.ATTACHMENT);
email.send();
The problem is, the guy at the other end says "the header info has a Content-Transfer-Encoding value of "7bit" and it needs to be "quoted-printable".
My question is, how do I make this change so the file is attached in the appropriate way?
Rob
Upvotes: 3
Views: 2401
Reputation: 15872
Commons email decides based on the content of the attachment which encoding to use, see http://thecarlhall.wordpress.com/2010/09/01/setting-quoted-printable-in-a-commons-email-body-part/ for some related discussion. Also the underlying java-mail seems to do this automatically according to the javadoc.
The blog-post states that you can try to use
email.addHeader("Content-transfer-encoding", "quoted-printable");
but it may corrupt other parts of the mail as a result.
Upvotes: 1