cancel
Showing results for 
Search instead for 
Did you mean: 

File to Mail - Dynamic Attachment Name with Content

former_member210091
Participant
0 Kudos
160

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:/" + "/sap.com/xi/XI/System/Mail", "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;

Thanks,

View Entire Topic
manoj_khavatkopp
Active Contributor
0 Kudos

Check the scenario 3  in this blog :

former_member210091
Participant
0 Kudos

Thanks for the reply Manoj. It is definitely a very nice article however it does not solves my problem because I am picking files from a NFS share which does not support attachments. Moreover I don't have any trigger file (like the blog uses FileToMail.mail).

Thanks

manoj_khavatkopp
Active Contributor
0 Kudos

Saif,

Addition to the above blog use the code from thread FTP to Proxy With Attachment | SCN which sets the input file as an output payload attachment.

Br,

Manoj

former_member210091
Participant
0 Kudos

Thanks Manoj but that doesn't helps much.

I am already getting the attachment correctly via the UDF but just need to add some dummy Body to the e-mail.

Thanks,