Sender's address from received mail
2 posts in topic
Flat View  Flat View

Posted By:   Anu_Subramanion
Posted On:   Wednesday, September 12, 2001 12:53 AM

how can i get the sender's address from the
received mail.if i use message.getFrom().getString()
it gives [Ljavax.mail.internet.InternetAddress@6fd0b7.
How to get it ?

thanx in advance.

Re: Sender's address from received mail

Posted By:   John_Zukowski  
Posted On:   Friday, September 14, 2001 11:20 PM

Your question was already asked and answered in the FAQ, had you checked there first.

Re: Sender's address from received mail

Posted By:   Kahro_Raie  
Posted On:   Thursday, September 13, 2001 12:48 AM

As you can see the method getFrom() returns an array Address[] so toString() doesn't work well.

The easy way would be like this:

message.getFrom()[ 0 ].getString(), because I really don't know how there could be more senders than one.

The nicer way would be:

Address[] senders = message.getFrom();
for ( int i = 0 ; i < senders.length ; i++ ) {
// identification lets you use more methods in case of InternetAddress
if ( senders[ i ] instanceof InternetAddress ) {
( ( InternetAddress ) senders[ i ] ).toUnicodeString() ;
} else {
senders[ i ].toString() ;
About | Sitemap | Contact