Reputation: 1738
I am trying to fetch/read my email using java mail API. I am using following line to read the 'To' field
System.out.println("TO:" + message.getRecipients(Message.RecipientType.TO));
And it is giving the following output :
TO:[Ljavax.mail.internet.InternetAddress;@6e1567f1
where as I want the output like
[email protected]
Upvotes: 1
Views: 68
Reputation: 17
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());
}
Upvotes: 0
Reputation:
Try it:
Address[] recipients = message.getRecipients(Message.RecipientType.TO);
for(Address address : recipients) {
System.out.println("TO:" + address.toString());
}
Upvotes: 3