我有一个用Java发送邮件的代码,看起来像下面的代码:
String to = "to@gmail.com";
String from = "from@gmail.com";
String host = "localhost";
//Get the session object
Properties properties = System.getProperties();
properties.setProperty("mail.smtp.host", host);
Session session = Session.getDefaultInstance(properties);
//compose the message
try{
MimeMessage message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
message.setSubject("Ping");
message.setText("Hello, this is example of sending email ");
// Send message
Transport.send(message);
System.out.println("message sent successfully....");
}catch (MessagingException mex) {mex.printStackTrace();}
有什么方法可以格式化我发送的消息,例如更改文本颜色或使某些文本变为粗体等。