Skip to Content
Author's profile photo Rahul Thunoli

SMTP class – Secure INET Factory utility

Most of interfaces in a company dealing with emails  have to have an email body together with the attachement. To accomplish this straight with an email adapter I always had to go, round about ways of manipulating the message payload using XSLT mapping or JAVA mapping . And it did work all the time . But i always wondered why can’t SAP add a very simple feature in email adapter , where you can specify your file path and name  and make it easier to handle attachments.

I realised it would be easier and much reusable if i write a Java webservice with a method that can handle an email body ,  attachment path , fromaddress , toaddress , subject line etc.

The SMTP class in the inet jscape factory has some very simple methods which can be used to compose en email easily.



public void sendEmail(
        String fromAddress,
        String toAddress,
        String directory,
        String emailBody,
        String subject) {

           Smtp mail = new Smtp();
            {    File f = new File(directory);


All you have to do is to create an EJB with one method with the above lines of code .

If you create a bean using NWDS (eclipse based ) it already provides you with an easy to use webservice creation wizard . Once you create all the necessary components for the webservice build the jar file out of it .


Next you create an EAR for the JAR and deploy it on the XI server .


Now you have an email service running on your XI server , ready to use,  which can invoked within any interface in XI using a SOAP receiver communication channel .

If you login to the wsnavigator of the XI server you would be able to see it there .

There you can download the wsdl . After you download it extract the archive . Go to the folder – porttypes  .

the file you see here can be used as the webservice external definition inside XI .

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Vijayashankar Konam
      Vijayashankar Konam
      Idea is good. But does not mandate the use of BPM for every interface that wants to make use of it??


      Author's profile photo Rahul Thunoli
      Rahul Thunoli
      Blog Post Author
      There is no need to use a BPM . You can invoke this service through a soap receiver adapter .
      Author's profile photo Vijayashankar Konam
      Vijayashankar Konam
      I understand that. If part of the requirement of the interface is to send a mail, then BPM is a must.
      The whole reason behind the interface is to send a mail.. then its a straight forward WS call.


      Author's profile photo Rahul Thunoli
      Rahul Thunoli
      Blog Post Author
      You create a separate service for the email and just send it multiple services in the receiver determination . Still i don't see any need for BPM .