Showing results for 
Search instead for 
Did you mean: 

Attach two files to mail using Java Mapping in SAP PI 7.31

Former Member
0 Kudos

Hi Experts,

I have a file to mail scenario in SAP PI 7.31 in which I have to pick multiple files of different types like XML and CSV
and send these as attachments in a single mail to the client with same filenames as attachments. The requirement is, the file adapter should pick the two files which is having the same name but with different extensions. Should I have to use Java Mapping? If so, please help me out with your replies.

EXAMPLE:If I am sending two files namely apple.xml, apple.csv then, the file adapter should pick the two files. If we give the two files as apple1.xml and apple2.csv even then the file adapter should pick the two files. The received mail should also show the same names in the attachments accordingly.

Accepted Solutions (0)

Answers (2)

Answers (2)

Active Participant
0 Kudos

You can use Sender File Adapter with additional files option

Former Member
0 Kudos

Hi Artem,

Thanks for your reply.Actually i have to set the name of the attachments dynamically as the same name of the files I am sending whether i have to use a java mapping or is there any module avilable for achiving this ...

I used the following java coding but,it s not setting the name dynamically

public class Dfilename extends AbstractTransformation {

public void transform(TransformationInput in, TransformationOutput out)

throws StreamTransformationException {

  // TODO Auto-generated method stub

  Collection<String> contentid=null;





  for(String id:contentid)


   Attachment attachment=in.getInputAttachments().getAttachment(id);

   byte[] content=attachment.getContent();

   String contenttype=attachment.getContentType();


   out.getOutputAttachments().setAttachment(out.getOutputAttachments().create(id, contenttype, content));





}  }


0 Kudos