How to send email with zip attachment – We often have assignment in SAP Project to develop some ABAP Program that could send the email.

We need to convert attachment into binary format, and to send data from internal table you need to convert internal table data into binary format.

We need to use these class and function moduel for sending email with attachment in SAP

CL_BCSUsing to send email SAP ABAP
CL_ABAP_ZIPUsing this to zip file, this is we will use to zip attachment
HR_KR_STRING_TO_XSTRINGUsing to convert string to xstring
SCMS_XSTRING_TO_BINARYUsing to convert xstring to binary format

Following these step to send email with zip attachment in SAP ABAP

Step 1. Declare CL_BCS class and create object for class CL_BCS.

Using CL_BCS you can send email body of 255 characters per line, then we need to put it into internal table.

Step 2 Pass the email document, subject to send request.

Step 3 Convert data into binary format

Declare internal table and fill the data into internal table , this data in internal table will be as attachment .

Declare string and then convert internal table into string with horizontal tab and new line.

Convert string data into xstring using function module HR_KR_STRING_TO_XSTRING.

Convert data into ZIP xstring using CL_ABAP_ZIP class by passing the xstring.

Convert xstring to binary format using function module SCMS_XSTRING_TO_BINARY and ZIP attachment to send request.

Step 4 Set sender and recipient.

Set recipient email address.

Step 5. Set send email to send request.

In some SAP Server, email sending will not be send immediately, because to reduce load of the server, this is configuration you can ask your BASIS team. but you can set immediately through ABAP Code.

Finally send email using send request.

Incoming search terms:

Leave a Reply

Your email address will not be published. Required fields are marked *