上代码, 已经导入了javax.mail-1.6.2.jar, jakarta.mail-api-2.1.3.jar 。 这2个jar包, 为什么还提示The constructor MimeMessage(Session) is undefined,The method getInstance(Properties, new Authenticator(){}) is undefined for the type Session ????
Session session = Session.getInstance(properties, new Authenticator() {
protected PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication("your-email@example.com", "your-password"); // 邮箱用户名和密码
}
});
// 创建邮件消息
MimeMessage message = new MimeMessage(session);