Specify Mail Resource Dialog Box
See Also
You use this dialog box to automatically generate code that sends an e-mail
from a Java file. You open the dialog box by right-clicking a Java file in the
Source Editor and choosing Insert Code > Send E-mail. The file must
be in an EJB module project or a standard web application project. You cannot
generate e-mail code in a free-form web application project.
You use the dialog box as follows:
- Specify the JNDI name of the resource.
- Under Service Locator Strategy, specify whether to generate inline lookup
code or use an existing service locator. You can click 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 address,
subject, and body as parameters.
- You have to configure the mail resource on the application server yourself.
If your project's target server is the GlassFish 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.
- See Also
- Using a Service Locator
Legal Notices