Commons-Email과 함께 생성 된 첨부 파일+html은 일부 이메일 클라이언트에 표시되지 않습니다.

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

문제

Apache Commons-Mail에서 org.apache.commons.mail.htmlemail 클래스를 사용하고 있습니다. 결국 일부 사용자는 이메일이 전자 메일 클라이언트에 Attachemnts가없는 것으로 표시된다고 불평합니다 (Outlook 2007 및 Lotus Notes에서보고 된 문제).

한 사용자가 문제를 분석하고 다음 링크를 보냈습니다.

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

나는 다른 사람들을 읽었습니다.이 문제로 인해 Raw 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
}

전에 경험 한 사람이 있습니까?

많은 감사드립니다.

요나스

도움이 되었습니까?

해결책

커먼 메일 버전 1.1에 문제가있는 것 같습니다. 1.2로 업그레이드하면 문제가 해결되는 것으로 보입니다.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top