我已经在此链接上尝试过字符集建议
但是电子邮件显示了 messageText 的确切值......没有呈现任何 HTML。
这是我当前的代码
import java.util.Properties;
import javax.mail.Address;
import javax.mail.Message;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;
String messageText = "<br/>THIS IS A TEST...<br/>!!!";
Properties props = new Properties();
props.setProperty("mail.transport.protocol", "smtp");
props.setProperty("mail.smtp.auth", "true");
props.setProperty("mail.smtp.ssl.enable", "true");
Session mailSession = Session.getInstance(props, null);
mailSession.setDebug(true);
Transport transport = mailSession.getTransport();
MimeMessage message = new MimeMessage(mailSession);
message.setSubject(messageSubject);
message.setContent(messageText, "text/html; charset=utf-8");
Address[] fromAddress = InternetAddress.parse ( "pleasedonotreplymessage@[removed]" ) ;
message.addFrom( fromAddress );
message.addRecipient(Message.RecipientType.TO, new InternetAddress(toAddress));
transport.connect("[removed]", "", "");
transport.sendMessage(message, message.getRecipients(Message.RecipientType.TO));
transport.close();
我宁愿不必安装其他方工具.. 这将需要对我当前的代码进行彻底的返工。