about java mail

hi forum

i am new in java mail so please tell me how to send automatic mail like in my leave module one submudule assign leaveis there In this submodule when i assigning the leave to employee so whenever i press the button submit then automatically mail should go in employee's inbox. actually i am using mvc framwowrk so how to create servlet handler theough java mail and i have already set the classpath related the javamail already

[449 byte] By [abhinay_31a] at [2007-11-27 6:41:25]
# 1

This will help you:-

public void postMail( String recipients[], String subject, String message , String from) throws MessagingException

{

boolean debug = false;

Properties props = new Properties();

props.put("mail.smtp.host", "localhost");

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

session.setDebug(debug);

Message msg = new MimeMessage(session);

InternetAddress addressFrom = new InternetAddress(from);

msg.setFrom(addressFrom);

InternetAddress[] addressTo = new InternetAddress[recipients.length];

for (int i = 0; i < recipients.length; i++)

{

addressTo = new InternetAddress(recipients);

}

msg.setRecipients(Message.RecipientType.TO, addressTo);

msg.addHeader("MyHeaderName", "myHeaderValue");

msg.setSubject(subject);

msg.setContent(message, "text/html");

Transport.send(msg);

}

Raaj_Rock_n_Rulesa at 2007-7-12 18:11:00 > top of Java-index,Java Essentials,Java Programming...
# 2

yes i done but when i am going to compile this programme its throughing the exception cannot find sysmbol constructor InternetAddress

addressTo=new Internetaddress(reciepnt) here error is there

i thing that array formate is not getting may be

InternetAddress[] addressTo = new InternetAddress[recipients.length];

abhinay_31a at 2007-7-12 18:11:00 > top of Java-index,Java Essentials,Java Programming...
# 3
Did you include the related jar file for your program... Check it out
Raaj_Rock_n_Rulesa at 2007-7-12 18:11:00 > top of Java-index,Java Essentials,Java Programming...
# 4
yes i have already included jar files i have so confused where is the problem
abhinay_31a at 2007-7-12 18:11:00 > top of Java-index,Java Essentials,Java Programming...