cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieval of attachment filename - receiver mail adapter

Former Member
0 Kudos

Hi,

I am using the mail adapter to receive an e-mail into PI. This e-mail has an attached CSV file.

First, I am using the PayloadSwapBean to swap the application playload to the attachment payload

Second, I am using the MessageTransformBean to transform the CSV file into an XML document

These are both working fine and the message is then passing into the relevant message mapping.

However, I would like to be able to use the attachment filename in the message mapping.

Can anyone advise how to do this for the mail adapter ?

I've done it loads of times for the file adapter but never the mail adapter (when using attachments) so I am a bit stumped.

Any advice greatly received.

Cheers

Colin.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Colin,

You can use xslt mapping for converting the payload into a csv file and also for setting the filename for the attachment. Use Content Type and Content Disposition in the xslt itself and in the Content Disposition specify your filename.

Former Member
0 Kudos

Hi,

I am using the SAP supplied beans to switch the payload and transform it not XSLT mapping.

Kind regards

Colin.

former_member190389
Active Contributor
0 Kudos

HI please tell if the XML payload is the mail package?

Former Member
0 Kudos

Yes it is.

bhavesh_kantilal
Active Contributor
0 Kudos

think you will need to write a custom module that reads the filename of the attachment and then puts it into some field in the main payload.

This blog has the code snippet to show how to dynamically set the name of the attachment. There should be a similar method to read the attachment name. ( I think there is a getName )

Don't have the java doc on me now, but will try to look up as well.

Regards

Bhavesh

former_member190389
Active Contributor
0 Kudos

I have created an adapter module for receiver mail adapter in which i wanted dynamic filenames

I think you can get the file name from content disposition or may be getName method

.

check the snippet for hints for adapter module using getName


Object obj = arg1.getPrincipalData();
msg = (Message) obj;
XMLPayload xmlPayload = msg.getDocument();
String FileName = xmlpayload.getName();

where arg1 is the parameter supplied by function

public ModuleData process(ModuleContext arg0, ModuleData arg1)

in the adapter module

Former Member
0 Kudos

Hi Progirl,

I want to dynamically set the name of attachment in receiver mail Communication Channel.

Example: IN__9907211000004_4048454000005_20081211_01000000002643

The first two numbers 9907211000004 & 4048454000005 I want to read it from the message

20081211 this is the date and

And againg this number 01000000002643 is read from message.

I read from your response. You had created adapter module for the similar purpose. Can you share it. Since I am new to writing Adapter Module.

Thank You in Advance.

Mukhtar