Skip to Content
avatar image
Former Member

Sending file name dynamically including body with out using mail package!!

  Hello Experts,

Need help on the below requirement!!! My scenario is IDoc to Mail. From PI end we need to send the attachment, body and file name to the corresponding recipients. Here is the below development i have made.

ESR part:

   

I have generated body as an attachment by using the below UDF and have mapped it by using Add Variable.

UDF for Body Generation as an attachment:

AbstractTrace trace = container.getTrace();

String content = "Mit freundlichen Gruessen,ThyssenKrupp Steel AG,Materialwirtschaft 1";

String mimeType= "text/plain;charset="+ "\"" + "uft-8" + "\"";

String strFileName = "BODY";

//strFileName = strPrefix  + strFileExtension;

  1. trace.addInfo(strFileName);

try

{

    GlobalContainer globalContainer = container.getGlobalContainer();

    OutputAttachments outputAttachments = globalContainer.getOutputAttachments();

    Attachment attachments = outputAttachments.create(strFileName, mimeType, content.getBytes());

    outputAttachments.setAttachment(attachments);

    return "";

}

catch(Exception e)

{

String exception = e.toString();

return exception;

}

Also I have handled the file Name,TO, Subject and CC with the following UDF and mapped as below

UDF for Dynamic configuration for handling the above:

MappingTrace objTrace = container.getTrace();

DynamicConfiguration objDynConfig;

DynamicConfigurationKey objDCKey;

final String NAMESPACE = "http://sap.com/xi/XI/System/Mail";

final String ATTRIBUTE1 = "THeaderTO";  //Recipients TO List

final String ATTRIBUTE2 = "THeaderSUBJECT"; // Subject of The Email

final String ATTRIBUTE3 = "XHeaderName3"; //ContentDisposition

final String ATTRIBUTE4 = "XHeaderName1";  //ContentType

final String ATTRIBUTE5 = "XHeaderName2"; //ContentDescription

//Date objDate = new Date();

//String strFomatedDate = "";

String strFileName = "";

//SimpleDateFormat objSDF = new SimpleDateFormat(strSuffixDateFormat);

try

{

objDynConfig = (DynamicConfiguration) container.getTransformationParameters().

get(StreamTransformationConstants.DYNAMIC_CONFIGURATION );

objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE3);

//strFomatedDate = objSDF.format(objDate);//get the current date and time for file name

strFileName = strPrefix  + strFileExtension; //setting the file name dynamically

strFileName = "attachment; filename=" + strFileName;

  • objTrace.addWarning(strFileName);
  • objDynConfig.put(objDCKey, strFileName);

strFileName = "text/plain;";

objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE4);

  • objTrace.addWarning(strFileName);
  • objDynConfig.put(objDCKey,  strFileName);

strFileName = strPrefix ;

objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE5);

  • objTrace.addWarning(strFileName);
  • objDynConfig.put(objDCKey, strFileName);
  1. container.setParameter(StreamTransformationConstants.DYNAMIC_CONFIGURATION, objDynConfig);

objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE1);

  • objDynConfig.put(objDCKey, ZEmail);

objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE2);

  • objDynConfig.put(objDCKey, Subject);

}

catch (Exception objException)

{

  • objTrace.addWarning(objException.getMessage());

}

return "";

Integration Builder Part:

Here are the below channel settings parameters for my received mail output without using mail package

Parameter Level Setting:


Module Level Setting:


So from the above development I have almost achieved my requirement except File name of the attachment .

Here is the below Output of my mail received:



I kindly request your help on the same so that I can complete my development.

Thanks a lot in advance!!!

Many Thanks,

Best Regards,

Prashanth Bharadwaj Ch.

pastedImage_2.png (40.1 kB)
pastedImage_4.png (25.2 kB)
pastedImage_5.png (12.8 kB)
Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 07, 2016 at 07:48 AM

    Hi Prashanth

    In your previous thread , I suggested following the blog by using a Java mapping to form the target payload. But I noticed that you are using UDFs instead.

    I've also mentioned that the modules (FCC, Swap, etc) that you configured at the beginning is no longer applicable, but it's still in your channel.

    I'm not really sure what approach you are using now.

    Can you post the output of your mapping?

    Rgds

    Eng Swee

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member Eng Swee Yeoh

      Thanks alot Eng for the answer!! Will try to implement the same and keep you posted!!

      Thanks again!! 😊😊

      Many Thanks,

      Best Regards,

      Prashanth Bharadwaj Ch.