cancel
Showing results for 
Search instead for 
Did you mean: 

SAP PI7.31 : Mail with multiple attachments - how to process via UDF

former_member183909
Active Participant
0 Kudos

Hi

wondering how I can approach this problem.   I have to read an Email with any number of attachments  - it can have between 1 and 4 or maybe more of different types (CSV,XLS,PDF,ZIP).  I need to read this email and extract the attachments to a folder.

Just to let you know I have done this OK for an email that I know only has 2 attachments ! Works perfectly - just no good for ?n? attachments !

   Mail Sender has AF_Modules/MultipartHeaderBean to add payload Attributes

   The message is sent to 2 Receivers

   Each Receiver File adapter then uses AF_Modules/DynamicConfigurationBean and AF_Modules/PayloadSwapBean

Problem is that when I do not know how many attachments there are.  So I will have to write a Java UDF mapping, perhaps using the classTransformationInput.

My question is : To create a Java UDF what should be structure of a sent Email message Type look like so I can feed that into a UDF to check what payload attachments there are etc ?.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member181985
Active Contributor
0 Kudos

Hi Jonny,

Is target directory common for all file types (attachments)?

If Yes, you can use payloadzipbean in sender mail adapter and then pass the entire single zip file to target folder. Use some script to extract the zip file

Regards,

Praveen Gujjeti

Former Member
0 Kudos

Jonny,

plz chk the below link .(This link help of the 80% for u ...)

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

Regards,

Mutti .

former_member183909
Active Participant
0 Kudos

Hi Mutti

I did try this earlier too - but I found that the zip and then subsequent unzip had the file names as Mail-Attachment1 and Mail-Attachment2 (although the content was fine). 

former_member181985
Active Contributor
0 Kudos

Indeed, that is standard behavior of payloadzip bean. May be you can try with my article:

Attachments zipping during Mapping

to zip attachments using a UDF or a java mapping which allows you to have original file names.

Best Regards,

Praveen Gujjeti

former_member183909
Active Participant
0 Kudos

What did your Source and Target Message Interface structure look like ?

former_member181985
Active Contributor
0 Kudos

As long as you use java mapping, you can have any dummy structures for your interfaces.

But, if you prefer to use graphical mapping with UDF, then you should have some valid structures for your mail and file interfaces. e.g., mail pack XSD for mail interface as metioned by Indrajit Sarkar

and again the same structure for the file interface as well so that you can have one to one mapping an then make use of UDF code from the article. Use payload swap bean in the receiver file channel to replace xml payload with Zipped attachments and then finally use script to unzip this zip file.

Rgds,

Praveen Gujjeti

Former Member
0 Kudos

Hi Jhonny

You can use the standard mail package as the message type while sending the email to PI.

I think the same scenario will work if you use any dummy interface as well when sending the

email.

Only you need to write a java mapping to look for the attachment and save them in a directory.

former_member183909
Active Participant
0 Kudos

thanks for the tip !.  I need some type of source message structure - so I could use a simple Blob structure ? So now on further research so far it seems that the Message Type must be named as ‘Mail’ and it must be present under the Namespace ‘http://sap.com/xi/XI/Mail/30’.

http://www.riyaz.net/sap/xipi-sending-emails-using-xi-mail-adapter/83/

Former Member
0 Kudos

Hi Jonny

Yes that is the standard mail package structure provided by sap. The XSD of the mail package is provided as an attachment in SAP Note 748024.

Please check the doc below for more details

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0964d7c-e66e-2910-24bb-ac535e4a5...