In this recipe, we will see how we can modify the existing program so that, instead of the SAP user, we can send the same e-mail to an Internet address. We will make a copy of the same program and add additional code. The class that is to be used, in this case, is cl_bcs_cam_address
(instead of the cl_sapuser_bcs
class). The method create_internet_address
will be used for creating Internet user addresses.
We will now see the changes we need to make to the given program:
myrecipient
object reference being based upon the class cl_sapuser_bcs
, we will use the class cl_cam_address_bcs
.create_internet_address
of the cl_cam_addess_bcs
class for creating an e-mail address.i_express
parameter assignment from the add_recipient
method call of the cl_bcs
class (since the e-mail is going to an e-mail address outside the SAP system, pop-up express messages are irrelevant).if_sender_bcs
for our e-mail address (that is, sender e-mail address).create_internet_address
method of the cl_cam_address_bcs
class. The created object is stored in the variable myemailaddress
defined earlier.set_sender
method of the cl_bcs
class.We made a copy of the program in the previous recipe. The class cl_cam_bcs_address
is used for defining the recipient user. Since we have the e-mail address of the recipient, we used the static method create_internet_address
of the cl_cam_address_BCS
class. The necessary recipient is returned because of the method call. This is later added to the send request, thus specifying the Internet address.
Once the COMMIT WORK
statement is executed, the e-mail is sent to the Internet user address. In the receiver's inbox, we will see our e-mail address as the sender (since the set_sender
method has been used).
E-mail transfers are complicated. It may be possible that the programming done is correct but the e-mails are not sent. From experience, many times the problems arising when testing programmatic e-mail sending are e-mail server configuration/routing problems.
18.191.97.85