Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Email From info 2

Status
Not open for further replies.

cleanair4me

Technical User
May 16, 2008
61
0
0
When I send mail in my Java it always outputs the from address with the email address as it should where the email goes to the person and the person can reply back to the sender email address:

From: smith@place.com
To: jones@place.com
Subject: Hello World



I would like to display the name and also have their email address available so the person can reply back to it:

From: John Smith <smith@place.com>
To: jones@place.com
Subject: Hello World



I was wondering if I could use this: to="John Smith <smith@place.com>"

My current email program:
Code:
        String to = "smith@place.com";
        String from = "jones@place.com";
        String host = "smtp.mycompany.net";
        Properties props = new Properties();
        props.put("mail.smtp.host", host);
        props.put("mail.debug", "true");
        Session session = Session.getInstance(props);
 
        try {
            // Instantiatee a message
            Message msg = new MimeMessage(session);
            ....
Please advise.
 
You need some functions about using JavaMail to read address book but it is not supported in JavaMail.

You have to find if there is special Java API supported by your mail server for reading address book, otherwise you have to match email address by yourself.


javax.mail.search.AddressStringTerm for matching address.
 
Thanks, It did work after I tested it.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top