dcsimg
How to get the real name of a sender ?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   julien_dupond
Posted On:   Monday, May 27, 2002 01:56 AM

When I receive a message under JavaMail, I want to get the real name of the sender but when I do a getFrom() I received a string like :

=?iso-8859-1?q?Julien=20Dupont?=


But I only want the real name...

How can I do to recover only "Julien Dupont" ?

Thanks

Ju

Re: How to get the real name of a sender ?

Posted By:   Christopher_Koenigsberg  
Posted On:   Tuesday, May 28, 2002 08:09 AM

You've got a string that is encoded in the standard for email headers, and you need to decode it.



I haven't used the JavaMail API myself but maybe "decodeText()" from "MimeUtility" would do what you need?



If you want to roll your own and do it yourself the good old-fashioned way, or just understand what is going on (the quoted-printable decoding):



The text encoding for email headers in the MIME RFC's is similar if not identical to MIME "quoted printable" content-transfer-encoding I think? with the addition of the charset prefix e.g. the "iso-8859-1" surrounded by question-mark quotes.



Quoted-printable content-transfer-encoding was the predecessor of, and similar to, but not identical to, the "URL encoding" of the HTML/HTTP RFC's.



For instance, "=20" is the quoted-printable encoding of the ASCII blank space character. The "=" is the escape prefix and the "20" is the ASCII value. The HTML/HTTP authors adapted this to "%20" instead, using "%" as the escape prefix.

About | Sitemap | Contact