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
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);
}
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];