我试图发送一个文件base64编码通过apache.commons.mail
,我只是不能缝到Content-Transfer-Encoding: base64
标题应该去的地方。Apache Commons电子邮件编码附加base64
// Create the email
MultiPartEmail email = new MultiPartEmail();
email.setSmtpPort(587);
email.setDebug(false);
email.setHostName("smtp.gmail.com");
email.setAuthentication("[email protected]", "password");
email.setTLS(true);
email.addTo("[email protected]");
email.setFrom("[email protected]");
email.setSubject("subject");
email.attach(new ByteArrayDataSource(
Base64.encodeBase64(attachFull.getBytes()), "text/plain"),
"samplefile.txt",
"sample file desc",
EmailAttachment.ATTACHMENT
);
这就是接收者所得到的。
------=_Part_0_614021571.1334210788719
Content-Type: text/plain; charset=Cp1252; name=texto.txt
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment; filename=samplefile.txt
Content-Description: sample file desc
如何指定该文件是Base64编码?
这可能会......我已经成功添加了一个'MimeMultipart()'(javax.mail)作为commons.mail的外部部件。但有些东西还是不对的。我可能会搞乱Base64编码。让我再深入一点... – Frankie 2012-04-12 07:04:52
接受你的答案,因为它让我走上正轨。作为参考发布我的。谢谢。 – Frankie 2012-04-12 07:19:19