Skip to Content
avatar image
Former Member

Dynamic Filename in Receiver mail adapter - is it possible without custom module or mail package?

Hello All,

We have implemented a file to receiver mail adapter scenario (PI 7.31) , the interface is a pass-through hence no ESR components involved.

Our requirement here is, the source file needs to be sent as mail attachment and attachment name should be dynamic i.e. target file name should be same as that of source file.

I have searched in SCN blogs and found below solutions :

  1. Using mail package ( We are not keen on implementing this as we don’t use any ESR components)
  2. Michal blog for creating custom module :

( Not sure if this will work as I see there are many developers commented in the same link that they are facing issues even after implementing this solution)

So , we are just looking if there are any other options apart from the above mentioned, in order to achieve the same. If anybody has achieved this through a different method, kindly let me know .

Thanks in advance.

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    Jan 14, 2015 at 09:03 AM

    Hi Kavita

    Without using mail package , you will not be able to create the attachment using dynamic name.

    You can use message transformation bean to rename the attachment but this will only allows static values.

    The simple solution would be use mail package and get the attchment name dynamically. You can do this either by graphical or java mapping.

    You have to fill these three fileds in the target mail package

    Content Type: text/xml

    Content Description: indratest.txt

    Content Disposition: attachment;filename="indratest.txt"

    Sample Java Mapping Code:

    package com.test;










    public class createAttachment extends AbstractTransformation {

    public void transform(TransformationInput arg0, TransformationOutput arg1)

    throws StreamTransformationException {

    try {

    InputStream is = arg0.getInputPayload().getInputStream();

    // get the file name from header

    DynamicConfiguration conf = arg0.getDynamicConfiguration();

    DynamicConfigurationKey dynKey = DynamicConfigurationKey.create(

    "", "FileName");

    String filename = conf.get(dynKey);

    // creating the attachment

    String ContentType = "text/xml";

    BufferedReader br = new BufferedReader(new InputStreamReader(is));

    String strLine;

    StringBuffer data = new StringBuffer();

    StringBuffer content = new StringBuffer();

    String ls = System.getProperty("line.separator");

    String firstline = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><ns1:Mail xmlns:ns1=\"\">";


    String lastline = "</ns1:Mail>";

    // Read File Line By Line

    while ((strLine = br.readLine()) != null) {

    // Print the content on the console




    String body = "<Subject>Test Mail using Mail Package in SAP PI</Subject><From></From><To></To><Content_Type>"

    + ContentType

    + "</Content_Type><Content_Description>"

    + filename

    + "</Content_Description><Content_Disposition>attachment;filename=&quot;"

    + filename

    + "&quot;</Content_Disposition><Content>"

    + content.toString() + "</Content>";



    // Close the input stream




    } catch (Exception e) {



    }// end of transform


    Add comment
    10|10000 characters needed characters exceeded

  • Jan 14, 2015 at 09:14 AM

    Hi Kavita,

    I think the main problem is that the attachment treatment changes between PI 7.0 and below to PI 7.1 and above. For example to PI 7.0: Adapter Module PI 7.0 Set Attachment Name - Process Integration - SCN Wiki

    If you don't want ESR development, neither custom module development, as far as i know there it not alternative.


    Add comment
    10|10000 characters needed characters exceeded

  • Sep 23, 2015 at 06:55 AM

    Hi Kavita,

    I have a similar requirement. Having a xyz.csv file in AL11 & i want that to be mailed as it is with same name to the recipients. If you have found out a solution for this kindly share the same. I don't want to use ESR, is it possible?

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Oct 05, 2015 at 10:39 AM

    Hi Kavitha,

    We have the same requirement in our project. Could you kindly share what solution was made in your case.


    Prabhu V

    Add comment
    10|10000 characters needed characters exceeded