java mail API required

I need an easy to use java mail API.

I will have a mail template where I would  send parameters to create mail content

also I will have a mail subject template where I would  send parameters to create subject content .

Can you suggest  a very easy to use mail api which I can use.

also a little example will help me a lot.
cofactorAsked:
Who is Participating?
 
CEHJCommented:
That's three separate mails in one session
0
 
gurpsbassiCommented:
Have you not tried the Java mail API that comes with Java?
Alternatively Apache Commons Email : http://commons.apache.org/proper/commons-email/
0
 
cofactorAuthor Commented:
I am using java 6.

It would better if I could put the template in a property file.  Is it possible ?

Is there any other API to look at ?

I want  simple and easy to use java mail API.
0
Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

 
CEHJCommented:
I haven't used Commons mail, so can't be certain, but the trouble with wrapped APIs in my experience is twofold:

a. they seldom simplify to any significant extent (if they did, it would imply the original API was badly designed)
b. you'd have access to much less support than the original API.

Moral of the story? Probably don't bother - use Java Mail

And yes, property files containing format strings (to be used with String.format) should be fine
0
 
cofactorAuthor Commented:
Hi,

CHEJ ,

I believe you meant something like this ..

String message = "This message is for {0} in {1}.";
String result = MessageFormat.format(message, "me", "the next morning");
System.out.println(result);


Ok....this looks fine.

However I want to send  mail in html format ? What settings I need to do in java mail ?
0
 
CEHJCommented:
I believe you meant something like this ..
You could use that but in some ways MessageFormat has been superseded by String.format. There are a number of reasons you should use the latter, among them:

a. there are fewer steps to the goal
b. knowing printf notation will give you reusable skills

Using html requires really only two things:

a. setting the content type to text/html
b. using html in your format strings
0
 
cofactorAuthor Commented:
OK....this looks good.

I may need to send mails  to different groups . They all have separate email templates though.

Is it possible  to send batch mails using java mails  ? if so ..how ?
0
 
CEHJCommented:
Batching to different groups is done simply by adding more addresses to an array in the message. That too can be looked up in a properties file
0
 
cofactorAuthor Commented:
I meant this way ...

list of address of group 1 with template 1

list of address of group 2 with template 2

list of address of group 3 with template 3


Now send all mail  at one go.   Is it possible ?

This is where I am stuck.
0
 
CEHJCommented:
:)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.