Skip to Content
0
Aug 05, 2017 at 08:54 AM

dynamic file name and content conversion for receiver mail adapter

289 Views

Hi All,

My requirement is From,To, Filename from xml message which is coming as proxy. so at receiver side i have used mail package. below is the mapping i performed.

for the content field i have mapped like below

below are the parameters for the channel

for the receiver root mail node i have used below UDF to generate the file name dynamically. but when the mail comes to my inbox it is showing FileName as MainDocument.txt. once i opened the attachment then only i can see my file name.in mapping level i have not mapped for type,description,disposition. please suggest what corrections i have to make?

MappingTrace objTrace = container.getTrace();
DynamicConfiguration objDynConfig;
DynamicConfigurationKey objDCKey;
final String NAMESPACE ="http://sap.com/xi/XI/System/Mail";
final String ATTRIBUTE3 ="XHeaderName3"; //ContentDisposition
final String ATTRIBUTE1 ="XHeaderName1";//ContentType
final String ATTRIBUTE2 ="XHeaderName2"; //ContentDescription
String strFileName ="";
try
{
objDynConfig = (DynamicConfiguration) container.getTransformationParameters().
get(StreamTransformationConstants.DYNAMIC_CONFIGURATION );
objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE3);
strFileName=Prefix;
strFileName="attachment; filename=" + strFileName;
objTrace.addWarning(strFileName);
objDynConfig.put(objDCKey, strFileName);
strFileName= "text/plain;";
objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE1);
objTrace.addWarning(strFileName);
objDynConfig.put(objDCKey,  strFileName);
strFileName = Prefix;
objDCKey = DynamicConfigurationKey.create(NAMESPACE, ATTRIBUTE2);
objTrace.addWarning(strFileName);
objDynConfig.put(objDCKey, strFileName);


container.setParameter(StreamTransformationConstants.DYNAMIC_CONFIGURATION, objDynConfig);
}


catch (Exception objException)


{


                objTrace.addWarning( objException.getMessage() );


}


return "";

Attachments

capture1.png (2.5 kB)
capture2.png (29.0 kB)
capture2.png (29.0 kB)
capture3.png (7.6 kB)