【问题标题】:Attachments+Html generated with commons-email doesn't show in some email clients使用 commons-email 生成的附件+Html 在某些电子邮件客户端中不显示
【发布时间】:2009-11-30 18:20:05
【问题描述】:

一段时间以来,我一直在使用来自 apache commons-mail 的 org.apache.commons.mail.HtmlEmail 类。最终,一些用户抱怨他们的电子邮件客户端上显示的电子邮件没有附件(Outlook 2007 和 Lotus Notes 中报告了此问题)。

一位用户甚至分析了问题并给我发了以下链接:

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
}

以前有人经历过吗?

非常感谢。

乔纳塔斯

【问题讨论】:

    标签: java email html-email apache-commons-email


    【解决方案1】:

    commons-email 1.1 版似乎有问题。升级到 1.2 似乎可以解决问题。

    【讨论】:

      猜你喜欢
      • 2015-09-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2010-12-09
      • 1970-01-01
      • 2012-11-18
      • 2018-07-04
      • 2013-01-31
      相关资源
      最近更新 更多