Showing results for 
Search instead for 
Did you mean: 

File to Mail - Dynamic Attachment Name with Content

0 Kudos

Hey All,

I need to build a File to Mail scenario. PI needs to pick files from a NFS folder (PDF,JPG,TIF etc) and send to a mailbox as an attachment. The attachment name must be same as source filename and the mail Content (aka body) must have some dummy data (e.g. E-Mail from PI. Do Not reply).

I have build the scenario using dummy Message Types (not using Mail Package) and below UDF and the process works fine but I am not able to find how to add some dummy content to mail body, can someone please help me with it

MappingTrace setAttachmentName_trc;

setAttachmentName_trc = container.getTrace(); 

String mailHeaderValue = "";

DynamicConfiguration conf = (DynamicConfiguration) container .getTransformationParameters().get(StreamTransformationConstants.DYNAMIC_CONFIGURATION);

  // try to create a key

  try {

   DynamicConfigurationKey keyM1 = DynamicConfigurationKey.create( "http:/" + "/", "XHeaderName1");

      mailHeaderValue = "attachment; filename=" + input;

conf.put(keyM1, mailHeaderValue);

} catch (Exception e) { 

setAttachmentName_trc.addWarning("caught exception: " + e   + " - probably no adapter-specific message attribute.");

  e.printStackTrace();   }

return input;


View Entire Topic
0 Kudos

Very Sorry, the code formatting didn't come out properly in my question