Skip to Main Content

Java EE (Java Enterprise Edition) General Discussion

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

How can casting to String to InternetAddress

843834Oct 13 2009
Hello, I have to send and email and I'm using a InternetAddres to set the Address and the personal. I'm doing something like this:
mensaje.setFrom(new InternetAddress(from.getAddress(),from.getPersonal()));
The problem is that I receive this information in one String, I receive one of these options:

Name <email>
<email>
Name Surname <email>

How can I do to create a InternetAddress using that.

InternetAddress from = new InternetAddress (email, Name);
InternetAddress from = new InternetAddress (email, null);
InternetAddress from = new InternetAddress (email, Name Surname);

Javamail have any method to create that or I have to do a manual casting? Taking the String and dividing when I show a <>?

Thanks!
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Nov 10 2009
Added on Oct 13 2009
0 comments
62 views