1
我一直在使用來自apache commons-mail的org.apache.commons.mail.HtmlEmail類一段時間。最終,一些用戶抱怨電子郵件顯示電子郵件客戶端上沒有附件(Outlook 2007和Lotus Notes中報告的問題)。使用commons-email生成的附件+ Html在某些電子郵件客戶端中不顯示
一個用戶甚至已經分析了問題,並送我下面的鏈接:
http://support.microsoft.com/kb/961940
我看過別人:已切換到原javax.mail API由於這個問題。
下面是其附加文件的部分代碼:
private void dummy(List<Map<String, byte[]>> attachments, String htmlText) throws EmailException {
HtmlEmail memail;
memail = new HtmlEmail();
memail.setHtmlMsg(htmlText);
memail.setTextMsg("Your mail client doesn't recognize HTML e-mails.");
Iterator<Map<String, byte[]>> iter = attachments.iterator();
while (iter.hasNext()) {
Map<java.lang.String, byte[]> map = iter.next();
Set<Entry<String, byte[]>> entries = map.entrySet();
for (Entry<String, byte[]> entry : entries) {
try {
ByteArrayDataSource bads = new ByteArrayDataSource(
entry.getValue(), null);
memail.embed(bads, entry.getKey());
// memail.attach(bads, entry.getKey(), ""); // if I use this, the html message
// gets displaced
} catch (IOException e) {
throw new EmailException(e);
}
}
}
// ... continues
}
有任何人都經歷之前?
非常感謝。
Jonathas的