cancel
Showing results for 
Search instead for 
Did you mean: 

How to send email with body and attachment

Former Member
0 Kudos

Hi Experts!

Happy New Year!

My requirement is when ever the file leaves from PI I have to send emails to particular users.

Inputs: Based on the country code we need to send email to recipient. Mail should contain body ( as

BofA Transmission OUTBOUND-Informational Message: Wed Dec 30 19:00:25 PST 2015

Preparing to send attached ePayables File to Bank of America.) and attachment.

Country Code and attachment will be coming to PI through proxy from ECC.

Please suggest me how to do this. As per my knowledge we can go with UDF. Please send me the code for this requirement.

Appreciate your quick reply.

Awaiting for your Kind Response.

Thanks,

Gayathri.

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member184720
Active Contributor
0 Kudos

>>Country Code and attachment will be coming to PI through proxy from ECC.


If the attachment  is coming from Proxy, i don't think you need to do something using UDF.

All you need to do is enable "keep attachments" in the receiver email channel.


Assign the recipient email ID based on the country code logic during the mapping and same goes with Body.

Former Member
0 Kudos

Hi Hareesh,

Thanks for your Reply.

1. I am getting attachment as xml file and I have to send it through mail as .xls.

2. Can you tell me the logic of mapping and how can I add body in the email (it contains date and time format too)

Thanks,

Gayathri.

former_member184720
Active Contributor
0 Kudos

>> I am getting attachment as xml file and I have to send it through mail as .xls.


i don't think this would be a good design to convert xml into Excel in PI mapping.

It shouldn't be very difficult to send the attachment as excel using ABAP proxies. 


>>>2. Can you tell me the logic of mapping and how can I add body in the email (it contains date and time format too)

Go through below blog.

you can provide date & time logic to Content field.

http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/9e6c7911-0d01-0010-1aa3-8e1bb1551...

Former Member
0 Kudos

Hareesh,

How can do it with Graphical mapping.

former_member186851
Active Contributor
0 Kudos

Refer the Logic I mentioned,It should work.

former_member184720
Active Contributor
0 Kudos

It can be done using the Java mapping/ XSLT but why do you want to do that in PI ? As i mentioned it should be easy to handle in SAP and avoids the complex transformations in PI.

Did you check with SAP team?

Former Member
0 Kudos

Yes Hareesh. I checked with them. the thing is we have to sent payment file as xml. but when it comes to email notification it should be in .xls.

And one more thing we have encryption also in middle ( forgot to add this).

We need to send the mail with (mentioned above ) body text and attachment (as .xls) to particular recipients based on country code.

Thanks.

former_member186851
Active Contributor
0 Kudos

Hello Gayathri,

can you refer the below links

Sending an email from UDF and including an atta... | SCN

Former Member
0 Kudos

Hi Raghu,

Checked the above 2 links. But I am not able to get it completely.

Thanks,

Gayathri.

former_member186851
Active Contributor
0 Kudos

Gayathri,

So your scenario is

Proxy-------PI----------file

                   |

                   |

                   |

                Mail(with proxy content whenever a proxy comes to PI)

is this correct?

Former Member
0 Kudos

correct. Mail will go once the file left from PI

former_member186851
Active Contributor
0 Kudos


Hello Gayathri.

1.For first flow Proxy to file will be normal

2.For second use the below logic in the mapping to convert to EXCEL and configure mail adapter with send as attachement option to send mail

Former Member
0 Kudos

Raghu,

As of now we don't have any mapping for sending mail.

Can you confirm me whether I can add this in existing mapping (sending file with dynamic file name and path).

In my requirement ABAP proxy will add 2 more fields Country  code and mail address.

Now I have to send mail by using these 2 values.

Thanks.

former_member186851
Active Contributor
0 Kudos

Gayathri,

As Harresh mentioned you can try in ECC.

If its for sure in PI means create 2 mappings one for sending message to File and other for this mail,Use the UDF to convert to XLS and othe date transformation logics.