我試圖發送一個文件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