我一直在使用org.apache.commons.mail.HtmlEmail类,从阿帕奇百科全书邮件,对于一些时间。最后,一些用户抱怨的电子邮件显示了他们的电子邮件客户端(在Outlook 2007和Lotus Notes报告的问题)上没有attachemnts。

一个用户甚至分析的问题,并送我下面的链接:

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的

有帮助吗?

解决方案

似乎有一个与公共电子邮件1.1版中的问题。升级到1.2似乎解决该问题。

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top