我正在使用
Apache Commons Email 1.1,我无法弄清楚如何将文件附加到HtmlEmail.如果我运行下面的代码,我会收到一封附有附件的电子邮件,但HTML邮件也会作为附件出现.
如果我不调用email.attach(),HTML消息就会如您所愿,但我需要HTML消息和附件.我错过了什么?
HtmlEmail email = new HtmlEmail();
email.setHostName("localhost");
email.addTo("test@mail.com", "Test");
email.setFrom("testapp@mail.com", "Test App");
email.setSubject("Test message");
email.setHtmlMsg("
EmailAttachment attachment = new EmailAttachment();
attachment.setPath(pdfPath);
attachment.setDisposition(EmailAttachment.ATTACHMENT);
email.attach(attachment);
email.send();