我想内联发送一个 html 和一个文本内容,但只有一个内联显示,另一个显示为附件。我的代码:
MimeMultipart multipart = new MimeMultipart();
String html = "<font size=\"5\">Test HTML</font>";
String text = "Test text + html";
BodyPart bodyparty = new MimeBodyPart();
bodyparty.setContent(text, "text/plain");
multipart.addBodyPart(bodyparty);
bodyparty = new MimeBodyPart();
bodyparty.setContent(html, "text/html");
multipart.addBodyPart(bodyparty);
message.setContent(multipart);
Transport transport = session.getTransport("smtp");
transport.connect(user_auth, user_password);
transport.sendMessage(message, message.getAllRecipients());
transport.close();
可能吗?谢谢!