Skip to Content
Author's profile photo Former Member

SAP Print Outputs or Attachments in Mail Body


          SAP print outputs which are being sent to Outlook, Gmail, Yahoo, etc. as an attachment ( either as a Word document or Excel or PDF etc.), can also be displayed directly in mail body by converting it into HTML format.


          This document deals with concept of displaying SAP print outputs (which are being sent as an attachment currently), directly in the mail body instead of attaching as an attachments with the mail.


         Attachments can be added to mail using some standard Function modules or by using OOPs concepts as shown in the below screenshots.


          These attachments can be opened either by single clicking in case of word, excel and any Microsoft products which will display the contents in the mail body or by double clicking in case of PDF which will open the documents separately.


           In case, if there are limited data to be sent to user, separate software is required to open the file to view the contents.


          Purpose of this document is to coin the idea of displaying the contents of the document directly in the mail body without adding any attachments separately. This can be achieved by converting the objects into HTML format and sending via mail. Objects like logos, internal table entries, hyperlinks, standard texts as well as normal texts from SAP can be send to mail body.

How it Works:

  • Send Logos to Mail body :

    • Logos which needs to be sent via mail should be uploaded in MIME repository as shown below:
      • Go to SE80. Click on MIME Repository.
      • Right click on Public and click Import MIME objects.
      • Once the file is selected, give name and description for the uploaded logo and press save button.
    • Uploaded logos can be accessed and converted to HTML by below mentioned steps.
    • To retrieve the image from MIME repository:

Interface: IF_MR_API

Method: GET

    • Pass the url to the exporting parameter and import the values in a structure or variable.
    • Convert the image to Xstring table form.
    • To attach the image in HTML body:




Content         => Xtring table form.

Filename       => any name with extension of the image format.

Extension      => JPG/BMP/… etc.

Description    => any description.

Content type => image/ (extension of the image format).

Length          => length of an image.

Content_id     => same as filename.

  • Send Internal tables to Mail body:

    • Internal tables which needs to be send directly to mail body can be converted to HTML by using below mentioned steps.
      • Fill the fields which is to be displayed as header text in a field catalog.
      • Use the below FMs to convert the header texts, layouts and internal table entries into HTML.
          • To convert the header texts into HTML.
          • To convert the layout of an internal table into HTML.
        • WWW_ITAB_TO_HTML
          • To convert an internal table entries into HTML.
          • If border is required, then pass table attributes as ‘BORDER=1’, if not then pass ‘BORDER=0’.
    • Final internal table (SOLI_TAB) should be filled with the above retrieved HTML contents.

  • Send Normal text to Mail body:

    •   Texts which needs to be displayed in the mail body (Only Left-alignment) can be passed directly from the program by using      below mentioned HTML tag.
      1. By directly passing the texts from program.
      2. By using Standard texts.

    • By directly passing the texts from program:
      • Below mentioned HTML tag can be used to pass texts to mail body.

‘<p><font size=”5″ face=”TIMES NEW ROMAN” color=”black” fontstyle=”bold”><b><required text>

      • Final internal table (SOLI_TAB) needs to be filled with above mentioned HTML tag.
    • By using Standard texts.
      • Use the FM READ_TEXT to retrieve data from any standard texts into an internal table.
      • Use the FMs which was mentioned above to convert an internal table to HTML. In this case, pass table attributes as ‘BORDER=0’.

  • Concluding steps to pass all the data to mail body:

    • To display the final output internal table (SOLI_TAB), below steps needs to be followed.
    • To create mail HTML body:




Content => Final output internal table (SOLI_TAB).

Filename => ‘sapwebform.htm’ “filename for HMTL form

Description => any description.

    • To create HTML using BCS class and attach HTML and image part to it:




Subject => any subject texts.



    • To create document:



    • To create sender, recipient and to send mail below class can be used:


    • Below output can be achieved in the mail body.



  1. No proprietary software like Microsoft office or Adobe reader is required to open the attached file, as the contents are directly getting displayed in the mail body.
  2. This approach is more helpful when there is a requirement to show limited data to recipient.

Assigned Tags

      Be the first to leave a comment
      You must be Logged on to comment or reply to a post.