2014-06-10 2 views
0

나는 아파치 commons-mail (v1.3.2)을 사용하여 PDF 첨부 파일로 주문 확인 전자 메일을 보냅니다. Outlook (웹 및 데스크톱 모두)에서 전자 메일이 문제없이 표시되지만 gmail 계정으로 보내면 메일 내용이 비어 있고 HTML 컨텐트가 별도의 "noname.html"파일에 첨부됩니다.Apache commons-mail 첨부 파일이있는 HtmlEmail : html이 Gmail에 noname.html로 첨부되어 있습니다.

내 코드 : 처음에는

 // Create mail instance using commons-mail and the hybris MailUtility class. 
     HtmlEmail htmlEmail = (HtmlEmail) MailUtils.getPreConfiguredEmail(); // creates a mail instance with set mail 
     htmlEmail.setCharset("UTF-8"); 
     htmlEmail.setHtmlMsg("this is <b>html text</b>); 

     // Part two is attachment 
      DataSource ds = new ByteArrayDataSource(mailAttachment.getData(), "application/pdf"); 
      htmlEmail.attach(ds, "attach.pdf", "generalconditions", EmailAttachment.ATTACHMENT); 
     } 

     //send mail 
     htmlEmail.send(); 

이 문제는 전망도 발생하지만 v1.3.2에 평민 메일 버전 1.1에서 전환하여이 문제를 해결했습니다.

htmlEmail.attach(attachment); 
+0

왜 hybris 태그 : 은 여전히 ​​ –

+0

getPreconfiguredEmail() 메서드는 Hybris MailUtils 클래스에 있습니다. 알려진 하이브리즘 문제 일 경우를 대비하여 태그를 추가하는 것이 유용 할 거라고 생각했습니다. – nexana

답변

1

당신은 당신이이 같은 이메일에 첨부 그런
EmailAttachment attachment = new EmailAttachment(); 
attachment.setPath(pdfFile.getPath()); 
attachment.setDisposition(EmailAttachment.ATTACHMENT); 

를 사용해야합니다 ...하지만 Gmail에 고정되어 있지?
+0

다음은 몇 가지 예입니다. https://commons.apache.org/proper/commons-email/userguide.html – Captainju