Skip to Content

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();
           
               
       
            mail.setHostname(“smtp.yourcompany.com”);
            mail.addFromAddress(fromAddress);
            mail.addToAddress(toAddress);
            mail.setSubject(subject);
            mail.setBody(emailBody);
            if(!directory.equals(“”))
            {    File f = new File(directory);
             
              mail.addAttachment(f);
           
                               
            }
            mail.setContentType(“multipart/mixed”);
            mail.send();

     }

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 .

To report this post you need to login first.

4 Comments

You must be Logged on to comment or reply to a post.

      1. 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.

        VJ

        (0) 
        1. Rahul Thunoli 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 .
          (0) 

Leave a Reply