Я не могу исправить свою ошибку. Я хочу программу, которая отправляет электронные письма нескольким людям. Это мой код пока ...
public static void sendEmailWithAttachments(String host, String port,
final String userName, final String password, String[] toAddress,
String subject, String message, String[] attachFiles)
throws AddressException, MessagingException {
// sets SMTP server properties
Properties properties = new Properties();
properties.put("mail.smtp.host", host);
properties.put("mail.smtp.port", port);
properties.put("mail.smtp.auth", "true");
properties.put("mail.smtp.starttls.enable", "true");
properties.put("mail.user", userName);
properties.put("mail.password", password);
// creates a new session with an authenticator
Authenticator auth = new Authenticator() {
public PasswordAuthentication getPasswordAuthentication() {
return new PasswordAuthentication(userName, password);
}
};
Session session = Session.getInstance(properties, auth);
// creates a new e-mail message
Message msg = new MimeMessage(session);
msg.setFrom(new InternetAddress(userName));
InternetAddress[] toAddresses = { new InternetAddress(toAddress) };
msg.setRecipients(Message.RecipientType.TO, toAddresses);
msg.setSubject(subject);
msg.setSentDate(new Date());
toAddress
в {new Internet Address(toAddress)}
- это часть, где говорится, что String [] не может быть преобразована в String.
InternetAddress[] toAddresses = { new InternetAddress(toAddress) };
Заранее спасибо за помощь:)