Skip to Content
Author's profile photo Former Member

EMail with System Accessor Lookup Service

The System Accessor is becoming very useful in Java Mapping. It has opened up new horizon and provided a great level of flexibility to the SAP PI users. My previous blog was to show the database interaction with help of System Accessor. Now here is another usage for sending email. Sending email from Java Mapping and UDF avoids the multi-mapping and so it eventually reduces the complexity of the interface.

Below is the code snippet which can be used in Java Mapping or UDF to send an email:


// String Variable to hold the Request XML

String strEMailSysRequest = “”;

// Channel Object with Mail Receiver Channel

Channel channelEMailSys = LookupService.getChannel(“BC_EMAIL”, “EMAIL_R_ COMMON”);

// System Accessor Object with Mail Receiver Channel Object

SystemAccessor accessorEMailSys = LookupService.getSystemAccessor(channelEMailSys);

// Convert the Request XML String to Input Stream

InputStream isEMailLookup = new ByteArrayInputStream(strEMailSysRequest.getBytes());

// Create XML Payload object with request input stream

XmlPayload payload = LookupService.getXmlPayload(isEMailLookup);

// Call System Accessor to process the Request data and return the response as XML Payload

XmlPayload result = (XmlPayload);

// Convert the XML Payload into Response XML String

String strEMailSysResponse = convertStreamToString(result.getContent());


The String strEMailSysRequest need to be prepared as below which is similar to the one which needs to be created using mail package:

<ns2:Mail xmlns:ns2=”“>

     <Subject>EMail Lookup Test</Subject>



      <Content>Hurreyyyyyyyyy, EMail Lookup Test Successful!!! </Content>


The response XML caputured in strEMailSysResponse was as below:

<xim:MailReceipt xmlns:xim=’‘>


      <Greeting>EMAIL.SERVER.NET Microsoft ESMTP MAIL Service ready at Sat, 18 Jul 2015 18:17:54 +0530</Greeting>




     <Subject>EMail Lookup Test</Subject>






Appreciate your feedback and comments on the System Accessor usages.

Assigned Tags

      You must be Logged on to comment or reply to a post.
      Author's profile photo Former Member
      Former Member

      excellent post..

      keep logging with your blogging

      Author's profile photo Hareesh Gampa
      Hareesh Gampa

      Thanks for your efforts

      I believe it should be XmlPayload result = (XmlPayload); ???

      Author's profile photo Former Member
      Former Member
      Blog Post Author

      Thanks Hareesh for pointing this out!

      The code is now corrected.