cancel
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)

former_member192851
Active Participant
0 Kudos

You can use Sender File Adapter with additional files option

http://chizztectep.blogspot.ru/2013/01/sender-file-adapter-with-additional.html

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 ...so 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;

  if(in.getInputAttachments().areAttachmentsAvailable())

  {

   contentid=in.getInputAttachments().getAllContentIds(true);

  }

  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));

  

  }

 

 

}  }

 

sateesh_adma
Participant
0 Kudos