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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

sending email using JavaMail

Status
Not open for further replies.

teryhox

Programmer
Dec 6, 2007
3
ZW
Hie.

I have an enterprise application on netbeans 6.0. I want it to send an email whenever a user registers. I have some Javamail code that i have put in an EJB session bean so what i'm not sure is how do in fire an event that calls the sendMail method?

The code in the session bean looks like this:

@Resource(name = "mail/hdsSession")
private Session mailhdsSession;

public void sendMail(String email, String subject, String body) throws NamingException, MessagingException {
MimeMessage message = new meMessage(mailhdsSession);
message.setSubject(subject);
message.setSentDate(new Date());
message.setFrom();
message.setRecipients(javax.mail.Message.RecipientType.TO, javax.mail.internet.InternetAddress.parse(email, false));
message.setText(body);
javax.mail.Transport.send(message);
}
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top