cancel
Showing results for 
Search instead for 
Did you mean: 

Reading attachment name through Mail Adapter

praveenreddy_bk
Participant
0 Kudos

Hi Guys,

How read the attachment extension name through mail Adapter. Working on SAP PI 7.31

In my scenario we will receive the .xlxs file or PDF.

I need to route to different mapping depends upon the extension of the file.

Do we need to create the new module or standard modules available?

can you share me your inputs on this.

Regards,

Praveen

Accepted Solutions (0)

Answers (3)

Answers (3)

former_member190293
Active Contributor
0 Kudos

Hi Praveen!

As far as I know you can't get payload name in mapping using UDF, only attachment id.

But you can get attachment name in adapter module by using Payload class for getting attachment name.

Regards, Evgeniy.

vicky20691
Active Contributor
0 Kudos

Hi Praveen,

You can get the name with the below udf

InputAttachments inputAttachments = globalContainer.getInputAttachments();

System.err.println("Starts here");

System.err.println(inputAttachments.areAttachmentsAvailable());

Collection<String> attachements = inputAttachments.getAllContentIds(true);

System.err.println("size of attachment list is " +attachements.size()  );

int i=0;

for (Iterator iterator = attachements.iterator();iterator.hasNext();) {

        String array_element =(String) iterator.next();

    System.err.println(" ids are "+ i++ +" value is"+ array_element);

    Attachment attachment =inputAttachments.getAttachment(array_element);

   String contentType= attachment.getContentType() ;

Regards,

Vikas

Harish
Active Contributor
0 Kudos

Hi Praveen,

Please check the below blog

http://scn.sap.com/docs/DOC-63349

regards,

Harish