Link to home
Start Free TrialLog in
Avatar of cofactor
cofactor

asked on

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.
Avatar of gurpsbassi
gurpsbassi
Flag of United Kingdom of Great Britain and Northern Ireland image

Have you not tried the Java mail API that comes with Java?
Alternatively Apache Commons Email : http://commons.apache.org/proper/commons-email/
Avatar of cofactor
cofactor

ASKER

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.
Avatar of CEHJ
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
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 ?
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
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 ?
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
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.
ASKER CERTIFIED SOLUTION
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
:)