Show TOC Start of Content Area

Procedure documentation Sending E-Mail Messages  Locate the document in its SAP Library structure

Procedure

1. Obtain the SMTP Protocol Implementation

The javax.mail.Transport object is used for sending e-mail messages. It is an abstract class that represents the SMTP protocol implementation.

You get a Transport object by using the getTransport("smtp") method of the session object.

2. Specify the SMTP Server

There are two ways to specify the connection settings for the respective SMTP server:

      Using the respective service property

You can specify an SMTP server to be used for all sending operations by setting the correct value for the Smtp property of the JavaMail Client Service. Its value represents the server name or address (for example: smtp.my.server).

You can set the value of this property using the NetWeaver Administrator.

More information: Java System Properties.

      Using the connect method of the Transport object

The connect method has variants that allow you to specify the server host, port and user account, if necessary.

If you do not specify a port for connection, the default SMTP port (25) is used.

3. Send the E-Mail Message

To send an e-mail message to a specified address, use the send(Message) method of the Transport object. As a prerequisite, you need to have a ready Messageobject representing the message content and additional attributes.

More information: Creating E-Mail Messages.

Example

The following source code sample illustrates getting the SMTP transport implementation and sending a ready e-mail message.

tr = ses.getTransport("smtp"); 

tr.send(message);

 

End of Content Area