You can acquire or set a Session object either by using or by not using a mail configuration. This section describes both methods of acquiring and setting up a Session object.
This section describes how to acquire and set up a Session object using a mail configuration.
Before you acquire a mail configuration, set the mail configuration and resolve the resource link. For details on mail configuration and resolving the resource link, see 6.3 Mail configuration settings in the uCosminexus Application Server Application Setup Guide. For details on resolving the resource link see 9.3.2 Reference definition of the main configuration in the uCosminexus Application Server Application Setup Guide.
An example of setting the mail configuration is described below. Create the attribute file as follows:
<?xml version="1.0" encoding="MS932"?> |
Furthermore, use the attribute setup command of the resource, and register the attribute file as a resource. An example of specifying the command is described below:
cjsetresprop -type mail -resname TheMailSession -c mail.xml |
A mail configuration is acquired using either an annotation or JNDI. Following are both the methods:
// Field variable |
Session session = null; |
When you do not use a mail configuration, you can acquire the Session object with the factory method of the Session class. In this case, as you cannot acquire the items to be set in the mail configuration, you need to specify the settings in the program.
java.util.Properties prop = new java.util.Properties(); |