cancel
Showing results for 
Search instead for 
Did you mean: 

File-to-Mail attachment without manipulating the payload

Former Member
0 Kudos

Hello, I have a requirement to pick a file from a file server and send it to receiver as an email attachment as-is. The key is that the system should not read the contents of the file (payload). I'm unsure how to go about this! Any help in this regard is appreciated! Thanks!

Accepted Solutions (1)

Accepted Solutions (1)

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Refer the configuration part of the receiver mail adapter in this [link|http://www.riyaz.net/sap/xipi-sending-emails-using-xi-mail-adapter/83/]. This might help you.

Former Member
0 Kudos

Hi Baskar, thank you for your response. The content of the input file is plain text and not XML. So, how does the design objects and sender communication channel look like? Thanks again!

baskar_gopalakrishnan2
Active Contributor
0 Kudos

Refer this [link |http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/a0a27c01-26b0-2c10-bd8a-94498efa7ff6]too...

Answers (1)

Answers (1)

Former Member
0 Kudos

You should find this helpful.....no need for a data/message definition or any mapping.

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/4383

Former Member
0 Kudos

Guy & Baskar, thank you for your response!

I've implemented the interface configuration based on the blog in Guy's response. It works except for one problem. The attachment in the mail gets the name "untitled.xml". Since there is no mapping involved, is it possible to keep the name as the same as the input file? If an adapter module is to be written, can you please provide a sample? Thanks for your help!

baskar_gopalakrishnan2
Active Contributor
0 Kudos

You might want to see the dynamic configuration & variable substitution and see how that helps for renaming the filename.

http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/13864

Former Member
0 Kudos

Baskar, the file name from the sender is available to me in the Dynamic Configuration. I used DynamicConfigurationBean (in the receiver mail communication channel) to save the file name in a variable (message.interface) as mentioned in the link you shared today and attempted to use PayloadSwapBean to set the content disposition of the payload (as attachment;filename=message.interface) before the mail adapter module is invoked hoping that the file name in the variable "message.interface" would be assigned to the attachment .

I wasn't sure if this would work. The email attachment name still came out as "untitled.xml". Is there a way in receiver mail adapter to set the attachment file name from ASMA?

baskar_gopalakrishnan2
Active Contributor
Former Member
0 Kudos

Baskar, are you implying that setting the attachment name can be achieved only by using the mail package format? As I mentioned in my earlier post in the thread, the intent is not to read the file content (& hence no mapping). The file has to be used as-is.

Former Member
0 Kudos

Thank you for your response Gabriel!

The approach mentioned in your link doesn't take care of taking the file name from sender and assign to the mail attachment. That has been my issue!

Former Member
0 Kudos

This is the single most irritating bit of XI ! I wish I had a dollar for every blog I've read on this subject..still no answer without writing beans.

Former Member
0 Kudos

Agreed! Looks like bean is the way to go! I'm leaving the thread open to update with the solution I implement.

Former Member
0 Kudos

I created a Java bean to read the file name available in Adapter-Specific Message Attribute (ASMA) and set it in the payload content type. Here is the code to be put in the process() method in the Java Bean:

String fileName;

Message msg = (Message) inputModuleData.getPrincipalData();

Payload payload = msg.getDocument();

MessagePropertyKey mpk = null;

mpk = new MessagePropertyKey("FileName", "http://sap.com/xi/XI/System/File");

fileName = msg.getMessageProperty(mpk);

if(fileName == null) fileName="mytestfile.txt";

payload.setContentType("text/plain;charset = \"UTF-ISO-8859-1\";" + "name=\"" + fileName + "\"");

inputModuleData.setPrincipalData(msg);

} catch (Exception e) {

throw new ModuleException(e);

}

return inputModuleData;

Thanks to all those that helped me addressing the issue.

Former Member
0 Kudos

Please explane how to achieve this/

Former Member
0 Kudos

Magnificent ! With your permission I shall plagiarize this.

Edited by: Guy Pengelly on Mar 2, 2012 3:25 AM