InternetAddress personal name is NULL from

Hi,

I am using Java Mail APIs to access Lotus IMAP Server. I am trying to get the Personal Name of the From Address in a Message. I have casted the Address Object to InternetAddress Object. There is no value for Personal Name. It returns NULL.

Here is the test code.

String host = "10.21.11.164";

String username = "test";

String password = "test";

Properties props = new Properties();

javax.mail.Session session = javax.mail.Session.getDefaultInstance(props, null);

Store store = session.getStore("imap");

store.connect(host, username, password);

Folder folder = store.getFolder("INBOX");

folder.open(Folder.READ_ONLY);

Message message[] = folder.getMessages();

for (int k=0, n=message.length; k<n; k++) {

Flags flags = message[k].getFlags();

System.out.println(message[k].getMessageNumber() + "\t" + message[k].getFrom()[0]

+ "\t" +message[k].getReceivedDate()+ "\t" + message[k].getReceivedDate()+ "\t" +flags.contains(Flags.Flag.SEEN)+"\t"+ message[k].getSubject());

InternetAddress inetAddress = (InternetAddress)message[k].getFrom()[0];

System.out.println(" Name : "+inetAddress.getPersonal());

}

folder.close(false);

store.close();

Here is the Output:

1TestingGuy002@nd.comTue May 22 16:08:20 EDT 200705/22/2007 04:08 PMtrueTest

Name : null

When I looked at the Domino Web Access and the Notes Client Mail, this message shows the Personal Name as "Test Guy" in the From Field.

Is there a way to get this Personal Name using mail api ?

Appreciate your help.

Thanks and Regards,

JK>

[1677 byte] By [J-Ka] at [2007-11-27 8:35:25]
# 1

The IMAP server parses the header and returns the email address and personal

name values as separate fields. Look at the IMAP protocol trace and you'll see

them. Or not. If the server doesn't return the information, JavaMail won't return

the information.

Most likely it's a bug in your server and it's not returning the personal name

information in the IMAP protocol response. Check the protocol trace to be sure.

bshannona at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 2
Thanks for your reply.Could you please explain more on the IMAP Protocol Trace ? Is it something to be looked at the IMAP server side or a java object needs to be traced ?Thanks and Regards,JK
J-Ka at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 3
Have you found the JavaMail FAQ yet?Turn on Session debugging and JavaMail will print out a protocol trace.
bshannona at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 4

I appreciate your reply. The JavaMail FAQ is very helpful. I have enabled the session trace and got the following trace.

JAVA MAIL APIs

==============

DEBUG: setDebug: JavaMail version 1.3.2

DEBUG: getProvider() returning javax.mail.Provider[STORE,imap,com.sun.mail.imap.IMAPStore,Sun Microsystems, Inc]

DEBUG: mail.imap.fetchsize: 16384

* OK Domino IMAP4 Server Release 6.5.4FP1 ready Tue, 26 Jun 2007 09:03:04 -0400

A0 CAPABILITY

* CAPABILITY IMAP4rev1 AUTH=PLAIN LITERAL+ NAMESPACE QUOTA UIDPLUS

A0 OK CAPABILITY completed

IMAP DEBUG: AUTH: PLAIN

A1 AUTHENTICATE PLAIN

+

UmF2aSBHdXB0YQBSYXZpIEd1cHRhAHJhdmkxNzA4

A1 OK AUTHENTICATE completed

A2 LIST "" INBOX

* LIST (\Noinferiors \HasNoChildren) "\\" Inbox

A2 OK LIST completed

DEBUG: connection available -- size: 1

A3 EXAMINE Inbox

* 1 EXISTS

* 0 RECENT

* OK [UIDVALIDITY 0] UIDs valid

* OK [UIDNEXT 4] Predicted next UID

* FLAGS (\Flagged \Seen \Answered \Deleted \Draft)

* OK [PERMANENTFLAGS ()] No permanent flags permitted

A3 OK [READ-ONLY] EXAMINE completed

Total Messages : 1

Unread Messages : 0

A4 FETCH 1 (FLAGS)

* 1 FETCH (FLAGS (\Seen))

A4 OK FETCH completed

A5 FETCH 1 (ENVELOPE INTERNALDATE RFC822.SIZE)

* 1 FETCH (ENVELOPE ("Tue, 22 May 2007 16:08:20 -0400" "Test" ((NIL NIL "Testing_Guy002" "nd.com")) ((NIL NIL "Testing_Guy002" "nd.com")) ((NIL NIL "Testing_Guy002" "nd.com")) ((NIL NIL "xxxxxx.yyyyyy" "nd.com")) NIL NIL NIL "<OF005490D7.859EEE4C-ON852572E3.006EA050-852572E3.006EA053@nd.com>") INTERNALDATE "22-May-2007 20:08:20 +0000" RFC822.SIZE 766)

A5 OK FETCH completed

1Testing_Guy002@nd.comTue May 22 16:08:20 EDT 200705/22/2007 04:08 PMtrueTest

Name : null

A6 CLOSE

A6 OK CLOSE completed

DEBUG: added an Authenticated connection -- size: 1

A7 LOGOUT

* BYE logging out

A7 OK LOGOUT completed

BUILD SUCCESSFUL (total time: 2 seconds)

I believe that I would need to look at the ENVELOPE of the message fetch. The envelope has "NIL NIL" just before the email internet address. That means the server doesn't provide the Personal Name.

Is that correct ? If so .. is it a bug in the imap server side ?, Is there a configuration required at server side ?

Thanks a lot for your reply. It is great help.

J-Ka at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 5
Yes, that's correct, it looks like the server isn't sending that information.Assuming the information really is there in the MIME header, that lookslike a bug in your server. You should probably report this to IBM and seewhat they say.
bshannona at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...
# 6
Thanks for your reply.
J-Ka at 2007-7-12 20:32:00 > top of Java-index,Enterprise & Remote Computing,Enterprise Technologies...