带附件的 html 电子邮件
我正在尝试使用 apache-commons-email 1.1。
如果我使用此代码(发送不带附件的电子邮件),html 正文将正确显示。
HtmlEmail email = new HtmlEmail();
email.setMailSession(mailSession);
email.setSubject(subject);
email.addTo(to);
email.setFrom(from);
email.setHtmlMsg(body);
email.send();
但是使用以下内容,电子邮件正文为空白,并且有一个名为“第 1.2 部分”的 html 附件(与我的 zip 附件一起),其中包含应该是电子邮件正文的内容:
HtmlEmail email = new HtmlEmail();
email.setMailSession(mailSession);
email.setSubject(subject);
email.addTo(to);
email.setFrom(from);
email.setHtmlMsg(body);
ByteArrayDataSource bads = new ByteArrayDataSource(zip, "application/zip");
email.attach(bads, "files.zip", "files");
email.send();
我该怎么做才能避免此问题?
ps 我尝试升级到 commons-email 1.2,但出于某种原因,maven 无法从 refractions.net 下载它。
I'm attempting to include a zip attachment with some html content in an email using apache-commons-email 1.1.
If i use this code, which sends an email without an attachment, the html body displays correctly.
HtmlEmail email = new HtmlEmail();
email.setMailSession(mailSession);
email.setSubject(subject);
email.addTo(to);
email.setFrom(from);
email.setHtmlMsg(body);
email.send();
however using the following, the email body is blank, and there is an html attachment (alongside my zip attachment) called "Part 1.2" containing what is supposed to be the email body:
HtmlEmail email = new HtmlEmail();
email.setMailSession(mailSession);
email.setSubject(subject);
email.addTo(to);
email.setFrom(from);
email.setHtmlMsg(body);
ByteArrayDataSource bads = new ByteArrayDataSource(zip, "application/zip");
email.attach(bads, "files.zip", "files");
email.send();
what can i do to avoid this problem?
ps i've tried to upgrade to commons-email 1.2 but maven breaks downloading it from refractions.net for some reason.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
已确认:这是 commons-email 1.1 的问题,已在 1.2 中修复。
CONFIRMED: this is a problem with commons-email 1.1 and it is fixed in 1.2.
你试过这个吗?
did you try this?