Gli allegati + HTML generati con posta elettronica comune non vengono visualizzati in alcuni client di posta elettronica

StackOverflow https://stackoverflow.com/questions/1821464

Domanda

Sto usando la classe org.apache.commons.mail.HtmlEmail, dalla posta comune di Apache, da un po 'di tempo. Alla fine, alcuni utenti si lamentano del fatto che l'e-mail non viene mostrato sul loro client di posta elettronica (problema segnalato in Outlook 2007 e Lotus Notes).

Un utente ha persino analizzato il problema e mi ha inviato il seguente link:

http://support.microsoft.com/kb/961940

Ho letto che altri: sono passati all'API javax.mail non elaborata a causa di questo problema.

Ecco la parte del codice che allega i file:

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
}

Qualcuno l'ha già sperimentato?

Grazie mille in anticipo.

Jonathas

È stato utile?

Soluzione

Sembra che si sia verificato un problema con la versione 1.1 di commons-email. L'aggiornamento a 1.2 sembra risolvere il problema.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top