(Optional) Create a service locator class to handle getting the reference
to the database.
Open the Java file from which you want to send the JMS message. The file
must be in an EJB module project or a standard web application project. You
cannot generate lookup code in a free-form web application project.
In the Source Editor, right-click the file and choose Enterprise Resources
> Send E-mail.
Specify the JNDI name of the mail resource on the application server.
Under Service Locator Strategy, specify whether to generate inline lookup
code or use an existing service locator. You can click the Browse to search
for the service locator class name.
Click OK.
The IDE creates two methods:
getSession. Looks up the mail resource and creates
a mail session.
sendMail. Constructs and send the e-mail.
The IDE also registers the resource reference in your module's general
deployment descriptor.
In your code, call the sendMail method and pass the e-mail adress,
subject, and body as parameters.
Notes:
You have to configure the JavaMail resource on the application server yourself.
If your project's target server is the Sun Java System Applciation Server,
you can use the JavaMail Resource template in the Sun Resources category of
the New File wizard.
If your project's target server is the Sun Java System Applciation Server,
the IDE automatically configures the resource reference in the application-specific
deployment descriptor. If you are deploying to a different application server,
you have to configure the server-specific deployment descriptors yourself.