我正在尝试使用java mail API获取/阅读我的电子邮件。 我正在使用以下行来阅读“收件人”字段
System.out.println("TO:" + message.getRecipients(Message.RecipientType.TO));
它提供以下输出:
TO:[Ljavax.mail.internet.InternetAddress;@6e1567f1
我希望输出像
xyz@gmail.com
答案 0 :(得分:3)
试一试:
Address[] recipients = message.getRecipients(Message.RecipientType.TO);
for(Address address : recipients) {
System.out.println("TO:" + address.toString());
}
答案 1 :(得分:0)
message.getRecipients(Message.RecipientType.Io)) returns an array of message.
Retrive a value from message array sample code snippet.
Address[] recipients = message.getRecipients(Message.RecipientType.TO);
for(Address address : recipients){
System.out.println(address.toString());
}